@zeevox of SentiPy and Sentiment Investor fame kindly requested automation to automagically decorate all callables in a given package with @beartype without needing to explicitly do so:
Is it necessary to annotate each function with @beartype? Is there a way of more concisely adding beartype everywhere automagically?
This feature request tracks our eventual (hopefully not too eventual) solution: a beartype import hook. Specifically:
- We need to implement a new AST-based
beartype.hook.beartype_everything() import hook inspired by typeguard's comparable typeguard.importhook.install_import_hook() function. That's only 162 lines of pure Python, which means this is mostly trivial, but it's a dense 162 lines, which means this might take an undefinable quantum of space-time.
- Interested third parties will then call our import hook at the top of their top-level
__init__ submodules to globally and transparently apply @beartype across their entire codebases.
Grab that popcorn! @leycec's Wild Ride is now boarding for an improved @beartype user experience (UX).
@zeevox of SentiPy and Sentiment Investor fame kindly requested automation to automagically decorate all callables in a given package with
@beartypewithout needing to explicitly do so:This feature request tracks our eventual (hopefully not too eventual) solution: a beartype import hook. Specifically:
beartype.hook.beartype_everything()import hook inspired by typeguard's comparabletypeguard.importhook.install_import_hook()function. That's only 162 lines of pure Python, which means this is mostly trivial, but it's a dense 162 lines, which means this might take an undefinable quantum of space-time.__init__submodules to globally and transparently apply@beartypeacross their entire codebases.Grab that popcorn! @leycec's Wild Ride is now boarding for an improved
@beartypeuser experience (UX).