-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit is the last in a commit chain improving the granularity of both exception and warning messages emitted for **PEP 526-compliant annotated variable assignments** (e.g., `muh_var: int | str = True`). Previously, @beartype provided *no* contextual metadata describing these assignments in these messages. @beartype now prefixes these messages with substrings describing the fully-qualified class, callable, and/or module directly performing these assignments. As example: * Global annotated variable assignments like this: ```python bad_global: str = 0xFEEDFACE ``` ...now yield violations like this: ``` beartype.roar.BeartypeDoorHintViolation: Global variable "__main__.bad_global" value 4277009102 violates type hint <class 'str'>, as int 4277009102 not instance of str. ``` * Local annotated variable assignments like this: ```python def bad_func(): bad_local: int = "This local is bad. It's bad. It knows it." bad_func() ``` ...now yield violations like this: ``` beartype.roar.BeartypeDoorHintViolation: Callable paga.__main__.bad_func() local variable "bad_local" value "This local is bad. It's bad. It knows it." violates type hint <class 'int'>, as str "This local is bad. It's bad. It knows it." not instance of int. ``` (*Forceful effluvia loves vials of ale!*)
- Loading branch information
Showing
7 changed files
with
200 additions
and
64 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
Oops, something went wrong.