Coverage for src/shephex/decorators/__init__.py: 100%
24 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-03-29 18:45 +0100
« prev ^ index » next coverage.py v7.6.1, created at 2025-03-29 18:45 +0100
1# ruff: noqa
2class DecoratorState:
4 def __init__(self):
5 self._active = True
7 def disable(self):
8 self._active = False
10 def enable(self):
11 self._active = True
13 @property
14 def active(self):
15 return self._active
17global decorator_state
18decorator_state = None
20def get_decorator_state():
21 global decorator_state
22 if decorator_state is None:
23 decorator_state = DecoratorState()
24 return decorator_state
26from contextlib import AbstractContextManager
28class disable_decorators(AbstractContextManager):
30 def __enter__(self):
31 get_decorator_state().disable()
33 def __exit__(self, *exc):
34 get_decorator_state().enable()
37from shephex.decorators.chain import chain
38from shephex.decorators.hexperiment import hexperiment
40__all__ = ['chain', 'hexperiment']