-
-
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.
This commit improves the readability of exceptions raised by edge-case `@beartype`-decorated callables annotated by one or more forward references while also failing to define the `__module__` dunder attribute, resolving issue #381 kindly submitted by dynamical Bostonian and bonafide real-life main character @femtomc (McCoy R. Becker). For unknown (and probably indefensible) reasons, the third-party `markdown-exec` package appears to define such horrifying callables. When confronted with such horrifying callables, the `@beartype` decorator now raises human-readable exceptions resembling: ```python beartype.roar.BeartypeDecorHintForwardRefException: Function muh_func() parameter "muh_arg" forward reference type hint "MuhType" unresolvable, as "muh_func.__module__" dunder attribute undefined (e.g., due to <function muh_func at 0x7f030d402160> being defined only dynamically in-memory). So much bad stuff is happening here all at once that @beartype can no longer cope with the explosion in badness. ``` Flex those burly exception messages, @beartype! Flex 'em! (*A flexible lexicon on iconic nicks!*)
- Loading branch information
Showing
2 changed files
with
56 additions
and
8 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