diff --git a/devlib/utils/misc.py b/devlib/utils/misc.py index de4944b..eb9dfd3 100644 --- a/devlib/utils/misc.py +++ b/devlib/utils/misc.py @@ -748,8 +748,7 @@ def batch_contextmanager(f, kwargs_list): yield -@contextmanager -def nullcontext(enter_result=None): +class nullcontext: """ Backport of Python 3.7 ``contextlib.nullcontext`` @@ -761,7 +760,20 @@ def nullcontext(enter_result=None): statement, or `None` if nothing is specified. :type enter_result: object """ - yield enter_result + def __init__(self, enter_result=None): + self.enter_result = enter_result + + def __enter__(self): + return self.enter_result + + async def __aenter__(self): + return self.enter_result + + def __exit__(*_): + return + + async def __aexit__(*_): + return class tls_property: