Should a function that returns a context-managed object be decorated by `@contextmanager`?
Should a function that returns a context-managed object be decorated by `@contextmanager`? Question: Say I have a function that returns a context-managed object, here a tempfile.TemporaryFile: import tempfile def make_temp_file(): """Create a temporary file. Best used with a context manager""" tmpfile = tempfile.NamedTemporaryFile() return tmpfile Is this safe as is or should this be wrapped …