Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding Python ≥ 3.9 requirement for validators #34

Closed
rsokl opened this issue May 26, 2021 · 2 comments
Closed

Regarding Python ≥ 3.9 requirement for validators #34

rsokl opened this issue May 26, 2021 · 2 comments

Comments

@rsokl
Copy link

rsokl commented May 26, 2021

Heya @leycec, I am excited to be messing around with beartype's new validators! A question about the Python ≥ 3.9 requirement: is there a reason why typing_extensions.Annotated cannot be used to enable use of validators with earlier versions of Python?

I tried rerunning the polygon_area example in your readme using typing_extensions.Annotated, but ended up eating dirt at the feet of BeartypeDecorHintNonPepException.

Congratulations on 0.7.0!

P.S. in the polygon_area, ndarray should be np.ndarray so that readers don't hit an import error.

@leycec
Copy link
Member

leycec commented May 27, 2021

...is there a reason why typing_extensions.Annotated cannot be used to enable use of validators with earlier versions of Python?

</double_facepalm>

I... somehow didn't think of the most obvious thing. Beartype definitely should support the full typing_extensions package, but currently doesn't do to asinine assumptions I made a year ago in the private beartype._util.hint.pep.utilhintpepget.get_hint_pep_sign() function we internally use to classify incoming type hints. Just "Blurgh!"

I consider this a critical issue – especially with validators now locked behind a Python version most users won't even be able to readily use for another year or two. Let's see what Uncle Leycec can do for everyone to patch in mostly worky typing_extensions support this week.

Thanks for the steady stream of bright ideas, Ryan! You shine a light on the dark spaces in our codebase, which is most of them. 🕯️ 🕯️ 🕯️

P.S. in the polygon_area, ndarray should be np.ndarray so that readers don't hit an import error.

@rsokl the MVP (Most Valuable Pythonista) right here. Let's fix that before I embarrass myself any further. 😓

leycec added a commit that referenced this issue May 27, 2021
This commit is the first in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit both implements and tests the new private
`beartype._util.py.utilpymodule.is_module()` tester required to
efficiently and safely detect optional third-party dependencies like
`typing_extensions` as well as resolving a trivial documentation
code-string error kindly noted by machine learning guru and all-around
stand-up paragon of GitHub virtue @rsokl. (*Felonious melons!*)
leycec added a commit that referenced this issue May 28, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit generalizes the existing
`beartype._util.hint.pep.utilhintpepget.get_hint_pep_sign()` getter to
transparently support both the `typing` and `typing_extensions` modules.
(*Distributional ebullience!*)
leycec added a commit that referenced this issue May 29, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit defines a new private
`beartype._util.hint.data.pep.utilhintdatapep` submodule declaring
globally usable signs agnostic of any Python version or module and thus
transparently supporting both the `typing` and `typing_extensions`
modules. (*Rancid ancillaries distil acidic artilleries!*)
leycec added a commit that referenced this issue May 31, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit internally restructures the private
`beartype._util.hint.data` subpackage for improved usability,
readability, and maintainability (URM). (*Stodgy budgies!*)
leycec added a commit that referenced this issue Jun 1, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit documents further internal restructing
required to resolve this issue in the private
`beartype._util.hint.data.datapep` submodule. To avoid "breaking the
build," all further commits in this commit chain will be isolated to a
new `fix-34` branch. (*Irascible rascals!*)
leycec added a commit that referenced this issue Jun 2, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit refactors the codebase to identify
user-defined generic type hints via the internal
`beartype._util.hint.data.pep.sign.datapepsigns.HintSignGeneric`
singleton rather than the external `typing.Generic` singleton as well as
resolving a subtle outstanding issue with generics under Python 3.6.
(*Evidential residence in identical residuals!*)
leycec added a commit that referenced this issue Jun 4, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit refactors the codebase to dramatically
simplify handling of the `typing.NoReturn` singleton.
(*Allegro allegations pull aggro!*)
leycec added a commit that referenced this issue Jun 5, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit refactors the codebase to identify
user-defined "new type" hints via the internal
`beartype._util.hint.data.pep.sign.datapepsigns.HintSignNewType`
singleton rather than the external `typing.NewType` factory function.
(*Disruptive eruption!*)
leycec added a commit that referenced this issue Jun 10, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit refactors the codebase to identify
type variables via the internal
`beartype._util.hint.data.pep.sign.datapepsigns.HintSignTypeVar`
singleton rather than the external `typing.TypeVar` class. (*Padded adders!*)
leycec added a commit that referenced this issue Jun 12, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit refactors the codebase to identify
forward references via the internal
`beartype._util.hint.data.pep.sign.datapepsigns.HintSignForwardRef`
singleton rather than the external `typing.ForwardRef` class as well as
dramatically simplifying the definition of sign sets with a new
`beartype._util.hint.data.pep.sign.datapepsignset` submodule. (*Thaumaturgic urges!*)
leycec added a commit that referenced this issue Jun 15, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit declares a new private
`beartype._util.data.hint.pep.sign.datapepsignmap.HINT_BARE_NAME_TO_SIGN`
dictionary global mapping from unsubscripting `typing` and
`typing_extensions` attribute names to their identifying signs. Notably,
this is the last commit of this branch expected to pass tests! *We are
now breaking everything, folks.* (*Counterfeit featherweights!*)
leycec added a commit that referenced this issue Jun 16, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit sanitizes identification of unsubscripted type
hints by both defining and calling a new private
`beartype._util.hint.pep.utilhintpeptest.is_hint_pep_subscripted()`
tester function. Previously, the codebase made unsafe and frankly
shameful assumptions about the incestuous relationship between hints and
their identifying signs. (*Incorrigible oncology!*)
leycec added a commit that referenced this issue Jun 19, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit concludes all prerequisites needed to fully
implement this refactoring while still passing tests. All subsequent
commits, which are the bulk of them, will temporarily break tests as an
unavoidable side effect of the severity of this refactoring. (*Clueless clavicles!*)
leycec added a commit that referenced this issue Jun 23, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit refactors the codebase to identify
tuple type hints via the internal
`beartype._util.hint.data.pep.sign.datapepsigns.HintSignTuple`
singleton rather than the external `tuple` class and `typing.Tuple`
singleton. This is likely to break under Python 3.6, but we currently
ignore that because *NOBODY* cares about Python 3.6. *NOBODY*! Okay,
somebody does. Sorry, somebody. (*Fallacious traces!*)
leycec added a commit that referenced this issue Jun 26, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit disastrously breaks literally everything by
finally committing to this refactoring by disemboweling the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Since everything is now broken, we can only devoutly pray for
a miraculously swift and just refactoring. (*Untimely turntables!*)
leycec added a commit that referenced this issue Jun 28, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Counterweight wights!*)
leycec added a commit that referenced this issue Jun 28, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Imponderable ponderosa!*)
leycec added a commit that referenced this issue Jun 28, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Crabby crabapples!*)
leycec added a commit that referenced this issue Jun 29, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Stubby tubers!*)
leycec added a commit that referenced this issue Jun 30, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit refactors the codebase to identify
tuple type hints via the internal
`beartype._util.hint.data.pep.sign.datapepsigns.HintSignTuple`
singleton rather than the external `tuple` class and `typing.Tuple`
singleton. This is likely to break under Python 3.6, but we currently
ignore that because *NOBODY* cares about Python 3.6. *NOBODY*! Okay,
somebody does. Sorry, somebody. (*Fallacious traces!*)
leycec added a commit that referenced this issue Jun 30, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit disastrously breaks literally everything by
finally committing to this refactoring by disemboweling the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Since everything is now broken, we can only devoutly pray for
a miraculously swift and just refactoring. (*Untimely turntables!*)
leycec added a commit that referenced this issue Jun 30, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Counterweight wights!*)
leycec added a commit that referenced this issue Jun 30, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Imponderable ponderosa!*)
leycec added a commit that referenced this issue Jun 30, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Crabby crabapples!*)
leycec added a commit that referenced this issue Jun 30, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Stubby tubers!*)
leycec added a commit that referenced this issue Jun 30, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Stalky chalk!*)
leycec added a commit that referenced this issue Jul 2, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Inundated exudate!*)
leycec added a commit that referenced this issue Jul 3, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Provisional revisionism!*)
leycec added a commit that referenced this issue Jul 8, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit refactors the codebase to identify
tuple type hints via the internal
`beartype._util.hint.data.pep.sign.datapepsigns.HintSignTuple`
singleton rather than the external `tuple` class and `typing.Tuple`
singleton. This is likely to break under Python 3.6, but we currently
ignore that because *NOBODY* cares about Python 3.6. *NOBODY*! Okay,
somebody does. Sorry, somebody. (*Fallacious traces!*)
leycec added a commit that referenced this issue Jul 8, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit disastrously breaks literally everything by
finally committing to this refactoring by disemboweling the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Since everything is now broken, we can only devoutly pray for
a miraculously swift and just refactoring. (*Untimely turntables!*)
leycec added a commit that referenced this issue Jul 8, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Counterweight wights!*)
leycec added a commit that referenced this issue Jul 8, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Imponderable ponderosa!*)
leycec added a commit that referenced this issue Jul 8, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Crabby crabapples!*)
leycec added a commit that referenced this issue Jul 8, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Stubby tubers!*)
leycec added a commit that referenced this issue Jul 8, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Stalky chalk!*)
leycec added a commit that referenced this issue Jul 8, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Inundated exudate!*)
leycec added a commit that referenced this issue Jul 8, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Provisional revisionism!*)
leycec added a commit that referenced this issue Jul 9, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Accidental dentistry!*)
leycec added a commit that referenced this issue Jul 13, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Accidental dentistry!*)
leycec added a commit that referenced this issue Jul 13, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Trumpeting strumpets!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit refactors the codebase to identify
tuple type hints via the internal
`beartype._util.hint.data.pep.sign.datapepsigns.HintSignTuple`
singleton rather than the external `tuple` class and `typing.Tuple`
singleton. This is likely to break under Python 3.6, but we currently
ignore that because *NOBODY* cares about Python 3.6. *NOBODY*! Okay,
somebody does. Sorry, somebody. (*Fallacious traces!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit disastrously breaks literally everything by
finally committing to this refactoring by disemboweling the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Since everything is now broken, we can only devoutly pray for
a miraculously swift and just refactoring. (*Untimely turntables!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Counterweight wights!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Imponderable ponderosa!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Crabby crabapples!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Stubby tubers!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Stalky chalk!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Inundated exudate!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Provisional revisionism!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Accidental dentistry!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the next in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, en route to resolving #34. Once finalized, this will
enable usage of beartype validators under Python < 3.9 via this hint.
Specifically, this commit continues disastrously breaking literally
everything by continuing to disembowel the feckless
`beartype._util.hint.data.pep.datapep` submodule and its untrustworthy
`beartype._util.hint.data.pep.proposal` crony subpackage in favour of
`beartype._util.hint.data.pep.sign`, which is the only subpackage left
standing. Save us from our reckless selves, GitHub! (*Trumpeting strumpets!*)
leycec added a commit that referenced this issue Jul 14, 2021
This commit is the last in a commit chain adding transparent support
for the third-party `typing_extensions.Annotated` type hint back-ported
to Python < 3.9, both resolving #34 and enabling usage of beartype
validators under Python < 3.9 via that hint. Since we technically have
yet to exhaustively test `typing_extensions` support, that issue
remains temporarily open but should be formally resolved shortly.
(*Triumphant triumvirate!*)
@leycec
Copy link
Member

leycec commented Jul 14, 2021

"Well, that escalated quickly." — Ron Burgundy

After a ludicrous chain of 24 codebase-breaking commits, commit 25 finally restores the ignominious fix-34 branch to worky and has thus been merged into mainline.

Behold, data science goodfellows! The upcoming beartype 0.8.0 (...to be released shortly, for certain definitions of "shortly") now globally supports all typing_extensions attributes across all Python versions, which means beartype validators are now universally usable:

$ ipython3.8
>>> from beartype import beartype
>>> from typing_extensions import Annotated
>>> @beartype
... def muh_func(muh_annotated_str: Annotated[str, 'Holy balls.']) -> None:
...    print(muh_annotated_str)
>>> muh_func("I can't believe it's not typing.")
I can't believe it's not typing.

Thus ends another frayed neural ganglion of my sanity. 🤯

@leycec leycec closed this as completed Jul 14, 2021
leycec added a commit that referenced this issue Aug 18, 2021
This release brings undeniable support for **typed NumPy arrays** (i.e.,
`numpy.typed.NDArray` type hints), **typing backports** (i.e., public
public attributes of the third-party `typing_extensions` package,
enabling typing_ types introduced by newer Python versions to be used
under older Python versions), and **portable beartype validators**
(i.e., `beartype.vale` type hints usable under *all* Python versions via
the `typing_extensions.Annotated` backport). This release resolves **4
issues** and merges **2 pull requests.** Changes include:

## Compatibility Improved

* **Typed NumPy arrays** (i.e., `numpy.typed.NDArray` type hints). The
  `@beartype` decorator now transparently supports the third-party
  `numpy.typing.NDArray` type hint newly introduced by NumPy >= 1.21.0,
  resolving issue #42 kindly submitted by NumPy extraordinaire @Antyos.
  Note that usage of typed NumPy arrays under Python < 3.9.0 requires
  installation of the third-party `typing-extensions` package, which
  `@beartype` will then automagically detect and leverage internally.
* **Typing backports** (i.e., `typing_extensions` type hints). The
  `@beartype` decorator now transparently supports all public type hints
  of the third-party `typing_extensions` package, resolving issue #34
  kindly submitted by Ryan Soklaski (@rsokl) of considerable *MIT Beaver
  Works Summer Institute* and *Python Like You Mean It* fame.
  Note that usage of typed NumPy arrays under Python < 3.9.0 requires
  installation of the third-party `typing-extensions` package, which
  `@beartype` will then automagically detect and leverage internally.
* **Python < 3.9.0 beartype validators.** The `@beartype` decorator now
  portably supports **beartype validators** (i.e., `beartype.vale`
  objects annotating `typing{_extensions}.Annotated` type hints) across
  all Python versions, *also* resolving issue #34 kindly submitted by
  Ryan Soklaski (@rsokl). <sup>hallowed be his username</sup> Note that
  usage of beartype validators under Python < 3.9.0 requires:
  * Installation of the third-party `typing-extensions` package.
  * Annotation of `beartype.vale` objects by
    `typing_extensions.Annotated` (rather than `typing.Annotated`).
* **Python >= 3.10.0 `typing.NewType` type hints.** This release
  resolves a minor incompatibility recently introduced by Python
  3.10.0rc1, which (*waitforit*) broke backward compatibility with prior
  implementations of the public `typing.NewType` type hint. Previously,
  that hint was implemented as a closure; Python ≥ 3.10 fundamentally
  refactored that hint to a pure-Python class instance – significantly
  complicating cross-version detection. *yuwastemytime,* CPython?
* **Binary dunder method return annotations** (i.e., dunder methods
  accepting exactly two arguments). Previously, `@beartype` adopted
  mypy's permissive approach of implicitly coercing the return
  annotations of binary dunder methods returning only booleans to
  instead return `typing.Union[bool, type(NotImplemented)]`. `beartype`
  now expands that approach to *all* binary dunder methods regardless of
  return annotation. Thanks to pull request #40 from Matt Bogosian
  (@posita), Dropbox's positive code genius!

## Compatibility Broken

* **None.** This release preserves backward compatibility with the prior
  stable release.

## Issues Resolved

* **#44,** documenting beartype's new project shield generously ginned
  up by Matt Bogosian (@posita), Dropbox's positive code genius.
* **#42,** enabling typed NumPy arrays to be used under both Python ≥
  3.9.0 natively *and* Python < 3.9.0 via the
  `typing_extensions.Annotated` backport.
* **#40,** including:
  * **Fake builtin types** (i.e., non-builtin classes erroneously
    masquerading as builtin). Previously, `@beartype` incorrectly
    generated syntactically invalid code for decorated callables
    annotated by one or more fake builtin types – which, miraculously,
    there are hardly any of. Still... *it's not a good look, beartype.*
    Thanks to Matt Bogosian (@posita), Dropbox's positive code genius,
    for first detecting this horrifying edge case in pull request #40.
* **#34,** enabling beartype validators to be used under Python < 3.9.0
  via the `typing_extensions.Annotated` backport.

## Documentation Revised

* **Badge** (i.e., shield intended for display by downstream projects).
  Our front-facing `README.rst` documentation now provides a
  post-installation advisory suggesting public declaration of @beartype
  project compatibility with reST- and Markdown-friendly text exhibiting
  a beautiful @beartype badge. Unsurprisingly, @posita made that too...
  because what doesn't @posita do? Nuthin'! I'm pretty sure that means
  @posita does everything.

## Tests Improved

* **Optional dependencies.** Our GitHub Actions-based continuous
  integration (CI) configuration now installs optional test-time
  dependencies. Although `beartype` has *no* mandatory runtime
  dependencies, fully exercising all tests necessitates installing these
  test-time dependencies:

  * mypy, enabling tests for mypy-based PEP 561 compliance.
  * NumPy, enabling tests for `numpy.typing.NDArray` type hints. This
    proved surprisingly non-trivial. Apple's patently broken
    "Accelerate" BLAS replacement (as documented at numpy/numpy#15947)
    blocks NumPy ≥ 1.18.0 installation under default CI configurations,
    necessitating that we:
    * Only conditionally install `pip` packages with `--force-reinstall`
      under macOS. CI gonna CI.
    * Avoid installing NumPy altogether under macOS + PyPy, where even
      the `--force-reinstall` option fails to improve matters. You can
      only do so much when your core platform is fundamentally broken.
      Thanks, Apple.
  * `typing_extensions`, enabling tests for `typing` attributes
    unavailable under the active Python interpreter.

Thanks yet again to Badge Connoisseur @posita for his tremendous
efforts – which we are now eternally indebted to and can only repay
across the span of several gruelling lifetimes. "It will all be worth
it," I tell my future self.

(*Clogged clogs and unlogged cogs!*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants