def function_9(): """function with context manager""" with contextlib.redirect_stdout(sys.stderr): pass with contextlib.redirect_stdout(sys.stderr) as spam: # type: object pass