@contextlib.contextmanager
def report_scope(observation):
 current = _reporters[(-1)]
 old = current.observation
 current.observation = observation
 (yield)
 current.observation = old

@ contextlib . contextmanager def report_scope ( observation ) : current = _reporters [ ( - 1 ) ] old = current . observation current . observation = observation ( yield ) current . observation = old
returns a report scope with the current reporter .