Restore Python 3.11 support with conditional imports#15175
Merged
Conversation
cfaa38e to
f13a15f
Compare
Reverts the Python 3.11 drop from PR #15121. This restores: - requires-python >= 3.11 in pyproject.toml - typing_extensions conditional dependency for Python < 3.12 - Conditional imports for TypedDict, Protocol, TypeAliasType from typing_extensions on Python < 3.12 - The find_pre_312 tokenizer path in inputtransformer2.py for system assignments (a = !foo) where ! is ERRORTOKEN on 3.11 - Version-gated sys.last_exc usage (added in Python 3.12) - Python 3.11 in CI test matrix and oldest-deps job - Version check in setup.py and IPython/__init__.py - Enum autoreload test for Python < 3.12 Add tip about D.E. Shaw funding Python 3.11 support On Python < 3.12, include a random tip noting that IPython support for Python versions outside of SPEC-0 is funded by D.E. Shaw. Partial revert of #15121
2e2c089 to
acad273
Compare
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR restores Python 3.11 support to IPython 9.x, reverting the previous deprecation. Python 3.11 continues to be supported thanks to funding from the D. E. Shaw group.
Key Changes
TypedDictandProtocolimported fromtyping_extensionson Python < 3.12TypeAliasTypeimported fromtyping_extensionson Python < 3.12sys.last_excwhich only exists in Python 3.12+SystemAssign.find()intofind_pre_312()andfind_post_312()methods to handle differences in Python's tokenizer between versionstyping_extensions>=4.6as a conditional dependency for Python < 3.12Implementation Details
The changes maintain backward compatibility with Python 3.11 while preserving support for newer versions. Version checks are performed at import time where necessary, and runtime checks are used for features like
sys.last_excthat may not exist in earlier versions. The tokenizer changes account for differences in how Python 3.11 and 3.12+ handle error tokens in system command assignments.