FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Drop support for Python 3.8 by Viicos · Pull Request #585 · python/typing_extensions · GitHub

Repository navigation

Drop support for Python 3.8 - #585

Merged
AlexWaygood merged 4 commits into
python:mainfrom
Viicos:drop-38
Apr 16, 2025
Merged

AlexWaygood merged 4 commits into
python:mainfrom
Viicos:drop-38

Conversation

Viicos commented Apr 16, 2025

Copy link
Copy Markdown
Contributor

Fixes #568.

Viicos commented Apr 16, 2025

Copy link
Copy Markdown
Contributor Author

Not sure if anything should be done here?

def _could_be_inserted_optional(t):
"""detects Union[..., None] pattern"""
# 3.8+ compatible checking before _UnionGenericAlias
if get_origin(t) is not Union:
return False

cc @Daraan

Daraan commented Apr 16, 2025

Copy link
Copy Markdown
Contributor

Not sure if anything should be done here?

def _could_be_inserted_optional(t):
"""detects Union[..., None] pattern"""
# 3.8+ compatible checking before _UnionGenericAlias
if get_origin(t) is not Union:
return False

cc @Daraan

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 

AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you, this overall looks great! I have a smattering of nits and a couple of substantive comments:

Comment thread src/test_typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated
Comment thread src/typing_extensions.py Outdated

AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

AlexWaygood merged commit 7cfb2c0 into python:main Apr 16, 2025
LmeSzinc added a commit to py38deps/typing_extensions that referenced this pull request Sep 11, 2026
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.
This file contains hidden or 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
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

Successfully merging this pull request may close these issues.

Drop support for Python 3.8

4 participants


Back | FazBrowse Home | New Git URL