| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Not sure if anything should be done here? typing_extensions/src/typing_extensions.py Lines 1337 to 1341 in 4525e9d cc @Daraan |
Sorry, something went wrong.
3.9 introduced _UnionGenericAlias. The code can now be adjusted to use it directly like this: def _could_be_inserted_optional(t):
"""detects Union[..., None] pattern"""
- # 3.8+ compatible checking before _UnionGenericAlias
- if get_origin(t) is not Union:
+ if not isinstance(t, typing._UnionGenericAlias):
return False |
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you, this overall looks great! I have a smattering of nits and a couple of substantive comments:
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
Restore the Python 3.8 code paths removed upstream in 4.14.0 (commit 7cfb2c0, "Drop support for Python 3.8", PR python#585), applied as a revert of that commit on top of the 4.16.0 tag with the conflicts accumulated in 4.14.0-4.16.0 resolved: - requires-python >= 3.8, 3.8 classifier, py38 tox env, 3.8/pypy3.8 CI matrix entries, package description and docs updated to 3.8+ - reinstate the 3.8 implementations of Annotated/_AnnotatedAlias, TypeAlias, TypeGuard, TypeIs, TypeForm, Concatenate, Required, NotRequired, ReadOnly, Unpack, ParamSpec, get_origin/get_args and the hasattr(typing, ...) probes, plus the 3.8 branches of get_type_hints() and evaluate_forward_ref() - keep the 4.16.0 aliasing mechanism: Annotated is only assigned from typing when it exists, and Union is bound unconditionally so that the 3.8 branches are visible to ruff's static analysis - apply the upstream issue python#661 fix to the 3.8 Unpack alias as well (call typing._GenericAlias.__getitem__ directly instead of using zero-arg super() inside a class body that assigns __class__), so isinstance() results no longer depend on whether a profiling function is set - provide the 3.9+ subscription of arbitrary TypedDict and NamedTuple types on 3.8 as well. On 3.9+ it comes for free from dict.__class_getitem__ / tuple.__class_getitem__, neither of which exists before PEP 585, and upstream 4.13.x deliberately left it out. Non-generic TypedDict/NamedTuple classes now get a __class_getitem__ returning typing._GenericAlias, with the same __origin__/__args__/__parameters__ and instantiation behaviour as 3.9+ - tests: exercise the PEP 585-dependent cases through typing aliases instead of skipping them (evaluate_forward_ref nested/globals/owner, get_original_bases, NamedTuple subscription) and drop the 3.8 assertions that the above makes obsolete; unskip test_missing__name__ (the fix is present in the 3.8 releases CI installs); drop the Literal[[], []] deduplication assertion that CPython 3.13.15/3.14.7 made obsolete (same change as upstream 79c903c) - drop the daily scheduled runs, which serve the upstream repository only: remove the "Third-party tests" workflow (a cron running the test suites of nine downstream projects) and the daily cron in ci.yml together with its create-issue-on-failure job Verified locally: unittest suite passes on cp38-cp314 (including the free-threaded builds), ruff clean, tox py38-py314 green.
| Back | FazBrowse Home | New Git URL |
Fixes #568.