harshil21 · GitHub

Pull Request Overview

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

  • Migrated all Optional[...] and Union[...] 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
File Description
src/telegram/_chatfullinfo.py Switched Optional[...] annotations to PEP 604 union syntax.
src/telegram/_chatboost.py Updated api_kwargs and type hints to union syntax in boost classes.
src/telegram/_chatbackground.py Migrated Optional to union syntax for chat background classes.
src/telegram/_chatadministratorrights.py Replaced Optional[bool] with `bool
src/telegram/_callbackquery.py Updated function signatures and return types to union syntax.
src/telegram/_business.py Converted Optional annotations to union syntax in business classes.
src/telegram/_botname.py Adjusted api_kwargs type to union syntax.
src/telegram/_botdescription.py Changed api_kwargs annotation to union syntax in description classes.
src/telegram/_botcommandscope.py Removed legacy Optional/Union imports and applied union annotations.
src/telegram/_botcommand.py Updated api_kwargs annotation to union syntax in bot command.
src/telegram/_birthdate.py Migrated Optional[int] to `int
src/telegram/main.py Changed _git_revision return type to `str
pyproject.toml Bumped requires-python to >=3.10 and updated Python version fields.
examples/contexttypesbot.py Updated example optional parameters to union syntax.
examples/chatmemberbot.py Changed return type of extract_status_change to union syntax.
docs/auxil/admonition_inserter.py Adjusted type hints in admonition inserter for union syntax.
changes/config.py Migrated Optional to union syntax in chango config.
README.rst Updated compatibility statement to Python 3.10+.
.pre-commit-config.yaml Adjusted pyupgrade hook args to --py310-plus.
.github/workflows/unit_tests.yml Removed 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"

Read the original on github.com ↗