-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Isomorphic non-closure wrapper support.
This commit generalizes the `@beartype` decorator to support *all* **isomorphic wrappers** (i.e., higher-level callables decorated by the standard `@functools.wraps` decorator for wrapping lower-level callables with additional functionality defined by even higher-level decorators such that those wrappers isomorphically preserve both the number and types of all passed parameters and returns by accepting only a variadic positional argument and a variadic keyword argument), partially resolving issue #295 kindly submitted by @patrick-kidger (Patrick Kidger) – the Best Google X Researcher of All Time, Clearly. Previously, @beartype only supported **isomorphic closure wrappers** (i.e., isomorphic wrappers defined as closures rather than non-closure callables). Now, @beartype supports both isomorphic closure wrappers *and* **isomorphic non-closure wrappers** (i.e., isomorphic wrappers defined as non-closure callables rather than closures). Notably, this is now fine: ```python from beartype import beartype from functools import wraps import inspect def muh_func(muh_arg: int): # <-- wat!? no @beartype? how can this be? pass @beartype # <-- oh, okay. here's the @beartype. phew. that was close @wraps(f) # <-- standard decorator idiom def muh_wrapper(*args, **kwargs): # <-- isomorphic non-closure wrapper pass ``` (*Idiomatically immaterial idiocy in a cyclic automata, mate!*)
- Loading branch information
Showing
12 changed files
with
246 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.