In reference to issue #10 I implemented basic configuration. As of right now the parts that work are enabling/disabling based on groups or globally, but not the recursion depth or iteration size. I wanted to get your feedback on these proposed changes before adding in those other variables (they will be harder to include)
The basic API is as follows.
To enable all runtime_validation decorators globally (to disable set to False)
enforce.config(enable=True)
To enable a group globally (again, to disable set to False)
enforce.set_group('foo', True)
To tag a decorator as part of a group use the group keyword.
@runtime_validation(group='foo')
def testfunc(a: typing.Any): return a
To enable a decorator locally
@runtime_validation(enable=True)
def testfunc(a: typing.Any): return a
Now this is super nice, as it now means that you can tag a bunch of validation decorators as something like "testing" and enable them only for the unittests.
In reference to issue #10 I implemented basic configuration. As of right now the parts that work are enabling/disabling based on groups or globally, but not the recursion depth or iteration size. I wanted to get your feedback on these proposed changes before adding in those other variables (they will be harder to include)
The basic API is as follows.
To enable all
runtime_validation
decorators globally (to disable set toFalse
)To enable a group globally (again, to disable set to
False
)To
tag
a decorator as part of a group use thegroup
keyword.To enable a decorator locally
Now this is super nice, as it now means that you can tag a bunch of validation decorators as something like "testing" and enable them only for the unittests.
The disabling is done via the built-in functionality on the
wrapt
library, referenced here: https://wrapt.readthedocs.io/en/latest/decorators.html#dynamically-disabling-decorators