Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove support for Python 3.9#4827

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
harshil21 wants to merge15 commits intomaster
base:master
Choose a base branch
Loading
fromrm-3.9
Open

Remove support for Python 3.9#4827

harshil21 wants to merge15 commits intomasterfromrm-3.9

Conversation

harshil21
Copy link
Member

@harshil21harshil21 commentedJun 13, 2025
edited
Loading

To be merged after#4825 and after python 3.9 reaches EOL in October

A lot of find and replace along with copilot agent edits.

Didn't use the new TypeGuard feature yet.match statements is also not used right now.

Bibo-Joshi reacted with hooray emoji
@harshil21harshil21 added the 🔗 pythonrelated technology: python labelJun 13, 2025
Copy link

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes support for Python 3.9 and fully adopts Python 3.10+ syntax and tooling.

  • Migrated allOptional[...] andUnion[...] type hints to PEP 604 union syntax (X | None,A | B).
  • Updated project configuration, CI, pre-commit, and documentation to require Python >= 3.10.
  • Adjusted examples and docs to match the new minimum Python version.

Reviewed Changes

Copilot reviewed 218 out of 218 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
src/telegram/_chatfullinfo.pySwitchedOptional[...] annotations to PEP 604 union syntax.
src/telegram/_chatboost.pyUpdatedapi_kwargs and type hints to union syntax in boost classes.
src/telegram/_chatbackground.pyMigratedOptional to union syntax for chat background classes.
src/telegram/_chatadministratorrights.pyReplacedOptional[bool] with `bool
src/telegram/_callbackquery.pyUpdated function signatures and return types to union syntax.
src/telegram/_business.pyConvertedOptional annotations to union syntax in business classes.
src/telegram/_botname.pyAdjustedapi_kwargs type to union syntax.
src/telegram/_botdescription.pyChangedapi_kwargs annotation to union syntax in description classes.
src/telegram/_botcommandscope.pyRemoved legacyOptional/Union imports and applied union annotations.
src/telegram/_botcommand.pyUpdatedapi_kwargs annotation to union syntax in bot command.
src/telegram/_birthdate.pyMigratedOptional[int] to `int
src/telegram/main.pyChanged_git_revision return type to `str
pyproject.tomlBumpedrequires-python to>=3.10 and updated Python version fields.
examples/contexttypesbot.pyUpdated example optional parameters to union syntax.
examples/chatmemberbot.pyChanged return type ofextract_status_change to union syntax.
docs/auxil/admonition_inserter.pyAdjusted type hints in admonition inserter for union syntax.
changes/config.pyMigratedOptional to union syntax in chango config.
README.rstUpdated compatibility statement to Python 3.10+.
.pre-commit-config.yamlAdjustedpyupgrade hook args to--py310-plus.
.github/workflows/unit_tests.ymlRemoved Python 3.9 from test matrix.
Comments suppressed due to low confidence (2)

pyproject.toml:34

  • Update the project classifiers to include Python 3.13 and 3.14 to match the CI test matrix and declared compatibility.
"Programming Language :: Python :: 3.12",

pyproject.toml:11

  • [nitpick] Consider adding an upper bound to the Python requirement (e.g., ">=3.10,<4.0") to prevent unintended installation on Python 4.x releases.
requires-python = ">=3.10"

@harshil21harshil21 added the 📋 do-not-merge-yetwork status: do-not-merge-yet labelJun 13, 2025
@harshil21
Copy link
MemberAuthor

harshil21 commentedJun 14, 2025
edited
Loading

So apparently python recommends using X | Y syntax but this fails in subtle ways and makes life harder in instances like these:

>>>fromtypingimportTypeAlias>>>a:TypeAlias="int">>>defthis(arg:a|None):pass...Traceback (mostrecentcalllast):File"<python-input-3>",line1,in<module>defthis(arg:a|None):pass~~^~~~~~TypeError:unsupportedoperand type(s)for|:'str'and'NoneType'

Now doingdef this(arg: "a | None"):pass will work and appear to be fine. However this fails when you try to evaluate the forward reference, which is why test_official fails right now.

TypeAlias is actually deprecated in favor oftype (py 3.12+). Using that will now not error ondef this(arg: a | None):pass, but still failstest_official, because the types aren't actually evaluated:

typeA=int|strb=A|floatexpected=int|float|strb==expected# Falseb=A.__value__|float# Force evaluationb==expected# True

Anyway so for now it seems we'll have to settle and keep using Optional/Union in some places...

Base automatically changed from3.14 tomasterJune 19, 2025 18:18
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@Bibo-JoshiBibo-JoshiAwaiting requested review from Bibo-Joshi

Assignees
No one assigned
Labels
📋 do-not-merge-yetwork status: do-not-merge-yet🔗 pythonrelated technology: python
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@harshil21

[8]ページ先頭

©2009-2025 Movatter.jp