-
-
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.
PEP 604-inconsistent type hint protection.
This commit almost entirely reverts the prior commit -- which, on second thought, was *not* entirely well-thought out. Now, @beartype explicitly prohibits all **PEP 604-inconsistent type hints** (i.e., object permissible as an item of a PEP 604-compliant new union whose machine-readable representation is *not* the machine-readable representation of this hint in new unions). PEP 604-inconsistent type hints induce non-deterministic behaviour in @beartype and *must* thus be explicitly detected and prohibited. This includes those produced by the third-party `nptyping` package, for which @beartype now raises cautionary PEP 604-specific exceptions resembling: ``` beartype.roar.BeartypeDecorHintPep604Exception: Type hint NDArray[Shape['N, N'], Float] inconsistent with respect to repr() strings. Since @beartype requires consistency between type hints and repr() strings, this hint is unsupported by @beartype. Consider reporting this issue to the third-party developer implementing this hint: e.g., >>> repr(NDArray[Shape['N, N'], Float]) NDArray[Shape['N, N'], Float] # <-- this is fine >>> repr(NDArray[Shape['N, N'], Float] | int) nptyping.ndarray.NDArray | int # <-- *THIS IS REALLY SUPER BAD* # Ideally, that output should instead resemble: >>> repr(NDArray[Shape['N, N'], Float] | int) NDArray[Shape['N, N'], Float] | int # <-- what @beartype wants! ``` (*Descrying inscriptions on inscrutable lutes!*)
- Loading branch information
Showing
11 changed files
with
354 additions
and
194 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
File renamed without changes.
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.