MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / nullcontext

Class nullcontext

tools/python-3.11.9-amd64/Lib/contextlib.py:752–776  ·  view source on GitHub ↗

Context manager that does no additional processing. Used as a stand-in for a normal context manager, when a particular block of code is only sometimes used with a normal context manager: cm = optional_cm if condition else nullcontext() with cm: # Perform operation, u

Source from the content-addressed store, hash-verified

750
751
752class nullcontext(AbstractContextManager, AbstractAsyncContextManager):
753 """Context manager that does no additional processing.
754
755 Used as a stand-in for a normal context manager, when a particular
756 block of code is only sometimes used with a normal context manager:
757
758 cm = optional_cm if condition else nullcontext()
759 with cm:
760 # Perform operation, using optional_cm if condition is True
761 """
762
763 def __init__(self, enter_result=None):
764 self.enter_result = enter_result
765
766 def __enter__(self):
767 return self.enter_result
768
769 def __exit__(self, *excinfo):
770 pass
771
772 async def __aenter__(self):
773 return self.enter_result
774
775 async def __aexit__(self, *excinfo):
776 pass
777
778
779class chdir(AbstractContextManager):

Callers 1

delimit_ifMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected