Skip to content

EOL of Py3.9#1726

Merged
JrooTJunior merged 9 commits intoaiogram:dev-3.xfrom
andrew000:drop-py3.9
Oct 6, 2025
Merged

EOL of Py3.9#1726
JrooTJunior merged 9 commits intoaiogram:dev-3.xfrom
andrew000:drop-py3.9

Conversation

@andrew000
Copy link
Contributor

@andrew000 andrew000 commented Oct 3, 2025

Due to EOL of Py3.9 - this PR is presented.

Enums, types, methods or Bot class not changed, Butcher must be reconfigured to auto-generate py3.10+ compatible code.


Changes:

  • Drop py3.9 and pypy3.9
  • Add pypy3.11 (testing) into tests.yml
  • Remove py3.9 from matrix in tests.yml
  • Refactor not auto-gen code to be compatible with py3.10+, droping ugly 3.9 annotation.
  • Replace some from typing imports to from collections.abc, due to deprecation
  • Add from __future__ import annotations and if TYPE_CHECKING: where possible
  • Add some noqa to calm down Ruff in some places, if Ruff will be used as default linting+formatting tool in future
  • Replace some relative imports to absolute
  • Sort __all__ tuples in __init__.py and some other .py files
  • Sort __slots__ tuples in classes
  • Split raises into msg and raise (EM101, EM102) to not duplicate error message in the traceback
  • Add Self from typing_extenstion where possible
  • Resolve typing problem in aiogram/filters/command.py:18
  • Concatenate nested if statements
  • Convert HandlerContainer into a dataclass in aiogram/fsm/scene.py
  • Bump tests docker-compose.yml redis:6-alpine -> redis:8-alpine
  • Bump tests docker-compose.yml mongo:7.0.6 -> mongo:8.0.14
  • Bump pre-commit-config black==24.4.2 -> black==25.9.0
  • Bump pre-commit-config ruff==0.5.1 -> ruff==0.13.3
  • Update Makefile lint for ruff to show fixes
  • Use pathlib instead of os.path
  • Bump redis[hiredis]>=5.0.1,<5.3.0 -> redis[hiredis]>=6.2.0,<7
  • Bump cryptography>=43.0.0 -> cryptography>=46.0.0 due to security reasons
  • Bump pytz~=2023.3 -> pytz~=2025.2
  • Bump pycryptodomex~=3.19.0 -> pycryptodomex~=3.23.0 due to security reasons
  • Bump linting and formatting tools

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Add pypy3.11 (testing) into `tests.yml`

Remove py3.9 from matrix in `tests.yml`

Refactor not auto-gen code to be compatible with py3.10+, droping ugly 3.9 annotation.

Replace some `from typing` imports to `from collections.abc`, due to deprecation

Add `from __future__ import annotations` and `if TYPE_CHECKING:` where possible

Add some `noqa` to calm down Ruff in some places, if Ruff will be used as default linting+formatting tool in future

Replace some relative imports to absolute

Sort `__all__` tuples in `__init__.py` and some other `.py` files

Sort `__slots__` tuples in classes

Split raises into `msg` and `raise` (`EM101`, `EM102`) to not duplicate error message in the traceback

Add `Self` from `typing_extenstion` where possible

Resolve typing problem in `aiogram/filters/command.py:18`

Concatenate nested `if` statements

Convert `HandlerContainer` into a dataclass in `aiogram/fsm/scene.py`

Bump tests docker-compose.yml `redis:6-alpine` -> `redis:8-alpine`

Bump tests docker-compose.yml `mongo:7.0.6` -> `mongo:8.0.14`

Bump pre-commit-config `black==24.4.2` -> `black==25.9.0`

Bump pre-commit-config `ruff==0.5.1` -> `ruff==0.13.3`

Update Makefile lint for ruff to show fixes

Add `make outdated` into Makefile

Use `pathlib` instead of `os.path`

Bump `redis[hiredis]>=5.0.1,<5.3.0` -> `redis[hiredis]>=6.2.0,<7`

Bump `cryptography>=43.0.0` -> `cryptography>=46.0.0` due to security reasons

Bump `pytz~=2023.3` -> `pytz~=2025.2`

Bump `pycryptodomex~=3.19.0` -> `pycryptodomex~=3.23.0` due to security reasons

Bump linting and formatting tools
@github-actions github-actions bot added the 3.x Issue or PR for stable 3.x version label Oct 3, 2025
@github-actions
Copy link

github-actions bot commented Oct 3, 2025

✔️ Changelog found.

Thank you for adding a description of the changes

@codecov
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ab32296) to head (afe1057).
⚠️ Report is 1 commits behind head on dev-3.x.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           dev-3.x     #1726    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          591       591            
  Lines        13876     13980   +104     
==========================================
+ Hits         13876     13980   +104     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
aiogram/__init__.py 100.00% <ø> (ø)
aiogram/client/context_controller.py 100.00% <100.00%> (ø)
aiogram/client/default.py 100.00% <100.00%> (ø)
aiogram/client/session/aiohttp.py 100.00% <100.00%> (ø)
aiogram/client/session/base.py 100.00% <100.00%> (ø)
aiogram/client/session/middlewares/base.py 100.00% <ø> (ø)
aiogram/client/session/middlewares/manager.py 100.00% <100.00%> (ø)
...gram/client/session/middlewares/request_logging.py 100.00% <100.00%> (ø)
aiogram/client/telegram.py 100.00% <100.00%> (ø)
aiogram/dispatcher/dispatcher.py 100.00% <100.00%> (ø)
... and 63 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JrooTJunior JrooTJunior requested a review from Copilot October 3, 2025 10:41
Copy link
Contributor

Copilot AI 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 following its end-of-life status and updates the codebase to use Python 3.10+ type annotations and features. The changes modernize type hints by replacing generic types from the typing module with built-in equivalents (e.g., Listlist, Dictdict), add from __future__ import annotations where appropriate, and update dependencies for security and compatibility reasons.

Key changes include:

  • Drop Python 3.9 support and update minimum requirement to Python 3.10
  • Modernize type annotations throughout the codebase
  • Update dependencies including Redis, cryptography, and development tools

Reviewed Changes

Copilot reviewed 94 out of 94 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pyproject.toml Updates Python version requirements, dependency versions, and build configuration
tests/test_utils/test_dataclass.py Removes Python 3.9 test cases
tests/docker-compose.yml Updates Redis and MongoDB versions, removes version specification
.github/workflows/tests.yml Removes Python 3.9 from test matrix, adds PyPy 3.11
examples/*.py Adds return type annotations and modernizes type hints
aiogram/**/*.py Comprehensive type annotation modernization and code refactoring
README.rst Updates Python version requirement in documentation
Makefile Adds ruff linting options and outdated dependency checker
.pre-commit-config.yaml Updates black and ruff versions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@andrew000 andrew000 requested a review from JrooTJunior October 4, 2025 16:05
@JrooTJunior JrooTJunior merged commit df7b16d into aiogram:dev-3.x Oct 6, 2025
20 checks passed
@andrew000 andrew000 deleted the drop-py3.9 branch December 2, 2025 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x Issue or PR for stable 3.x version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants