[util] add 'NullContext'
an even more minimal 'contextlib.nullcontext' that also works on older Python versions
This commit is contained in:
@@ -516,6 +516,15 @@ class LazyPrompt():
|
||||
return getpass.getpass()
|
||||
|
||||
|
||||
class NullContext():
|
||||
|
||||
def __enter__(self):
|
||||
return None
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
pass
|
||||
|
||||
|
||||
class CustomNone():
|
||||
"""None-style type that supports more operations than regular None"""
|
||||
__slots__ = ()
|
||||
|
||||
Reference in New Issue
Block a user