This commit is contained in:
Andrew 2026-02-15 20:35:05 +02:00 committed by GitHub
commit fb40e6ec4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 819 additions and 786 deletions

View file

@ -17,6 +17,3 @@ trim_trailing_whitespace = false
[**.rst]
indent_size = 2
[Makefile]
indent_style = tab

View file

@ -14,7 +14,7 @@ repos:
- id: "check-json"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.14.0'
rev: 'v0.15.0'
hooks:
- id: ruff
files: &files '^(aiogram|tests|examples)'

3
CHANGES/1770.misc.rst Normal file
View file

@ -0,0 +1,3 @@
Migrated from `hatch` to `uv` build system.
Removed legacy `Makefile` and introduced `Justfile` for task automation to support the new uv-based workflow.

145
Justfile Normal file
View file

@ -0,0 +1,145 @@
#!/usr/bin/env just --justfile
set shell := ["bash", "-c"]
set windows-shell := ["pwsh.exe", "-NoLogo", "-Command"]
package_dir := "aiogram"
tests_dir := "tests"
scripts_dir := "scripts"
examples_dir := "examples"
code_dir := f"{{package_dir}} {{tests_dir}} {{scripts_dir}} {{examples_dir}}"
reports_dir := "reports"
redis_connection := "redis://localhost:6379"
mongo_connection := "mongodb://mongo:mongo@localhost:27017"
# Documentation variables
locales := "uk_UA"
locale_targets := "docs-serve-" + locales
locales_pot := "_build/gettext"
docs_dir := "docs"
# =================================================================================================
# Environment
# =================================================================================================
[unix]
clean:
find . -name "__pycache__" -type d -exec rm -rf {} +
find . -type f -name "*.py[co]" -delete
find . -type f -name "*~" -delete
find . -type f -name ".*~" -delete
find . -name ".pytest_cache" -type d -exec rm -rf {} +
rm -rf *.egg-info
rm -f report.html
rm -f .coverage
rm -rf build dist site .cache .mypy_cache .ruff_cache {{ reports_dir }}
[windows]
clean:
-Get-ChildItem -Path . -Recurse -Name "__pycache__" -Directory | Remove-Item -Recurse -Force
-Get-ChildItem -Path . -Recurse -Include "*.pyc", "*.pyo" -File | Remove-Item -Force
-Get-ChildItem -Path . -Recurse -Include "*~", ".*~" -File | Remove-Item -Force
-Get-ChildItem -Path . -Recurse -Name ".pytest_cache" -Directory | Remove-Item -Recurse -Force
-Remove-Item -Path "*.egg-info" -Recurse -Force -ErrorAction SilentlyContinue
-Remove-Item -Path "report.html" -Force -ErrorAction SilentlyContinue
-Remove-Item -Path ".coverage" -Force -ErrorAction SilentlyContinue
-Remove-Item -Path "build", "dist", "site", ".cache", ".mypy_cache", ".ruff_cache", "{{ reports_dir }}" -Recurse -Force -ErrorAction SilentlyContinue
install: clean
uv sync --all-extras --group dev --group test
uv run pre-commit install
# =================================================================================================
# Code quality
# =================================================================================================
[default]
lint:
uv run ruff format --check --diff {{ package_dir }}
uv run ruff check --show-fixes --preview {{ package_dir }} {{ examples_dir }}
uv run mypy {{ package_dir }}
reformat:
uv run ruff format {{ code_dir }}
uv run ruff check --fix {{ code_dir }}
# =================================================================================================
# Tests
# =================================================================================================
test-run-services:
docker-compose -f tests/docker-compose.yml -p aiogram3-dev up -d
test: test-run-services
uv run pytest --cov=aiogram --cov-config .coveragerc tests/ --redis {{ redis_connection }} --mongo {{ mongo_connection }}
[unix]
test-coverage: test-run-services
mkdir -p {{ reports_dir }}/tests"
uv run pytest --cov=aiogram --cov-config .coveragerc --html={{ reports_dir }}/tests/index.html tests/ --redis {{ redis_connection }} --mongo {{ mongo_connection }}
uv run coverage html -d {{ reports_dir }}/coverage
[windows]
test-coverage: test-run-services
New-Item -ItemType Directory -Path "{{ reports_dir }}\\tests" -Force -ErrorAction SilentlyContinue | Out-Null
uv run pytest --cov=aiogram --cov-config .coveragerc --html={{ reports_dir }}/tests/index.html tests/ --redis {{ redis_connection }} --mongo {{ mongo_connection }}
uv run coverage html -d {{ reports_dir }}/coverage
test-coverage-view:
uv run coverage html -d {{ reports_dir }}/coverage
uv run python -c "import webbrowser; webbrowser.open('file://{{ invocation_directory() }}/reports/coverage/index.html')"
# =================================================================================================
# Docs
# =================================================================================================
docs-gettext:
uv run --extra docs bash -c 'cd {{ docs_dir }} && make gettext'
uv run --extra docs bash -c 'cd {{ docs_dir }} && sphinx-intl update -p {{ locales_pot }} -l {{ locales }}'
docs-serve *OPTS:
uv run --extra docs sphinx-autobuild --watch aiogram/ --watch CHANGES.rst --watch README.rst {{ docs_dir }}/ {{ docs_dir }}/_build/ {{ OPTS }}
docs-serve-uk_UA *OPTS:
just docs-serve "-D language=uk_UA" {{ OPTS }}
# =================================================================================================
# Project
# =================================================================================================
build: clean
uv build
bump *args:
uv run python scripts/bump_version.py {{ args }}
uv run python scripts/bump_versions.py
update-api:
uv run --extra cli butcher parse
uv run --extra cli butcher refresh
uv run --extra cli butcher apply all
just bump
towncrier-build:
uv run --extra docs towncrier build --yes
towncrier-draft:
uv run --extra docs towncrier build --draft
[unix]
towncrier-draft-github:
mkdir -p dist
uv run --extra docs towncrier build --draft | pandoc - -o dist/release.md
[windows]
towncrier-draft-github:
New-Item -ItemType Directory -Path "dist" -Force -ErrorAction SilentlyContinue | Out-Null
uv run --extra docs towncrier build --draft | pandoc - -o dist/release.md
prepare-release: bump towncrier-build
release:
git add .
git commit -m "Release $(uv run python -c 'from aiogram import __version__; print(__version__)')"
git tag v$(uv run python -c 'from aiogram import __version__; print(__version__)')

132
Makefile
View file

@ -1,132 +0,0 @@
.DEFAULT_GOAL := lint
package_dir := aiogram
tests_dir := tests
scripts_dir := scripts
examples_dir := examples
code_dir := $(package_dir) $(tests_dir) $(scripts_dir) $(examples_dir)
reports_dir := reports
redis_connection := redis://localhost:6379
mongo_connection := mongodb://mongo:mongo@localhost:27017
# =================================================================================================
# Environment
# =================================================================================================
.PHONY: clean
clean:
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -rf `find . -name .pytest_cache`
rm -rf *.egg-info
rm -f report.html
rm -f .coverage
rm -rf {build,dist,site,.cache,.mypy_cache,.ruff_cache,reports}
.PHONY: install
install: clean
uv sync --all-extras --group dev --group test
uv run pre-commit install
# =================================================================================================
# Code quality
# =================================================================================================
.PHONY: lint
lint:
uv run ruff format --check --diff $(package_dir)
uv run ruff check --show-fixes --preview $(package_dir) $(examples_dir)
uv run mypy $(package_dir)
.PHONY: reformat
reformat:
uv run ruff format $(code_dir)
uv run ruff check --fix $(code_dir)
# =================================================================================================
# Tests
# =================================================================================================
.PHONY: test-run-services
test-run-services:
@#docker-compose -f tests/docker-compose.yml -p aiogram3-dev up -d
.PHONY: test
test: test-run-services
uv run pytest --cov=aiogram --cov-config .coveragerc tests/ --redis $(redis_connection) --mongo $(mongo_connection)
.PHONY: test-coverage
test-coverage: test-run-services
mkdir -p $(reports_dir)/tests/
uv run pytest --cov=aiogram --cov-config .coveragerc --html=$(reports_dir)/tests/index.html tests/ --redis $(redis_connection) --mongo $(mongo_connection)
uv run coverage html -d $(reports_dir)/coverage
.PHONY: test-coverage-view
test-coverage-view:
uv run coverage html -d $(reports_dir)/coverage
uv run python -c "import webbrowser; webbrowser.open('file://$(shell pwd)/reports/coverage/index.html')"
# =================================================================================================
# Docs
# =================================================================================================
locales := uk_UA
locale_targets := $(addprefix docs-serve-, $(locales))
locales_pot := _build/gettext
docs_dir := docs
docs-gettext:
uv run --extra docs bash -c 'cd $(docs_dir) && make gettext'
uv run --extra docs bash -c 'cd $(docs_dir) && sphinx-intl update -p $(locales_pot) $(addprefix -l , $(locales))'
.PHONY: docs-gettext
docs-serve:
uv run --extra docs sphinx-autobuild --watch aiogram/ --watch CHANGES.rst --watch README.rst docs/ docs/_build/ $(OPTS)
.PHONY: docs-serve
$(locale_targets): docs-serve-%:
$(MAKE) docs-serve OPTS="-D language=$(subst docs-serve-,,$@)"
.PHONY: $(locale_targets)
# =================================================================================================
# Project
# =================================================================================================
.PHONY: build
build: clean
uv build
.PHONY: bump
bump:
uv run python scripts/bump_version.py $(args)
uv run python scripts/bump_versions.py
update-api:
uv run --extra cli butcher parse
uv run --extra cli butcher refresh
uv run --extra cli butcher apply all
@$(MAKE) bump
.PHONY: towncrier-build
towncrier-build:
uv run --extra docs towncrier build --yes
.PHONY: towncrier-draft
towncrier-draft:
uv run --extra docs towncrier build --draft
.PHONY: towncrier-draft-github
towncrier-draft-github:
mkdir -p dist
uv run --extra docs towncrier build --draft | pandoc - -o dist/release.md
.PHONY: prepare-release
prepare-release: bump towncrier-build
.PHONY: release
release:
git add .
git commit -m "Release $(shell uv run python -c 'from aiogram import __version__; print(__version__)')"
git tag v$(shell uv run python -c 'from aiogram import __version__; print(__version__)')

View file

@ -1,2 +1,4 @@
__version__ = "3.25.0"
import importlib.metadata
__version__ = importlib.metadata.version(__package__)
__api_version__ = "9.4"

View file

@ -161,14 +161,14 @@ When using :code:`uv`, prefix commands with :code:`uv run` to execute them in th
# Start documentation server
uv run sphinx-autobuild --watch aiogram/ docs/ docs/_build/
Or use the Makefile commands which now support :code:`uv`:
Or use the Justfile commands which now support :code:`uv`:
.. code-block:: bash
make install # Uses uv sync
make lint # Uses uv run
make reformat # Uses uv run
make test # Uses uv run
just install # Uses uv sync
just lint # Uses uv run
just reformat # Uses uv run
just test # Uses uv run
Making changes in code
----------------------
@ -197,11 +197,11 @@ Or with uv:
uv run ruff format aiogram tests scripts examples
uv run ruff check --fix aiogram tests scripts examples
Or simply use Makefile:
Or simply use Justfile:
.. code-block:: bash
make reformat
just reformat
Run tests
@ -221,11 +221,11 @@ Or with uv:
uv run pytest tests
Or use Makefile:
Or use Justfile:
.. code-block:: bash
make test
just test
Also if you are doing something with Redis-storage or/and MongoDB-storage,
you will need to test everything works with Redis or/and MongoDB:
@ -260,11 +260,11 @@ Or with uv:
uv run --extra docs sphinx-autobuild --watch aiogram/ docs/ docs/_build/
Or use Makefile:
Or use Justfile:
.. code-block:: bash
make docs-serve
just docs-serve
Docs translations
@ -291,11 +291,11 @@ Or with uv:
uv run --extra docs bash -c 'cd docs && make gettext'
uv run --extra docs bash -c 'cd docs && sphinx-intl update -p _build/gettext -l <language_code>'
Or use Makefile:
Or use Justfile:
.. code-block:: bash
make docs-gettext
just docs-gettext
Change the :code:`<language_code>` in example below to the target language code, after that
you can modify texts inside :code:`docs/locale/<language_code>/LC_MESSAGES` as :code:`*.po` files

View file

@ -1,10 +1,11 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
requires = ["uv_build>=0.10.2,<0.11.0"]
build-backend = "uv_build"
[project]
name = "aiogram"
description = 'Modern and fully asynchronous framework for Telegram Bot API'
version = "3.25.0"
readme = "README.rst"
requires-python = ">=3.10,<3.15"
license = "MIT"
@ -48,10 +49,6 @@ dependencies = [
"certifi>=2023.7.22",
"typing-extensions>=4.7.0,<=5.0",
]
dynamic = ["version"]
[tool.hatch.version]
path = "aiogram/__meta__.py"
[project.optional-dependencies]
fast = [
@ -94,10 +91,10 @@ docs = [
[dependency-groups]
dev = [
"ruff~=0.14",
"ruff~=0.15",
"mypy==1.10.1",
"toml~=0.10.2",
"pre-commit~=4.3",
"pre-commit~=4.5",
"packaging~=25.0",
"motor-types==1.0.0b4",
]
@ -118,6 +115,10 @@ Homepage = "https://aiogram.dev/"
Documentation = "https://docs.aiogram.dev/"
Repository = "https://github.com/aiogram/aiogram/"
[tool.uv.build-backend]
module-root = ""
module-name = "aiogram"
[tool.ruff]
line-length = 99
src = ["aiogram", "tests"]

View file

@ -122,7 +122,7 @@ class TestBot:
# https://github.com/Tinche/aiofiles#writing-tests-for-aiofiles
aiofiles.threadpool.wrap.register(MagicMock)(
lambda *args, **kwargs: aiofiles.threadpool.binary.AsyncBufferedIOBase(*args, **kwargs)
lambda *args, **kwargs: aiofiles.threadpool.binary.AsyncBufferedIOBase(*args, **kwargs) # noqa: PLW0108
)
mock_file = MagicMock()

View file

@ -178,8 +178,8 @@ class TestSimpleRequestHandler:
new_callable=AsyncMock,
) as mocked_silent_call_request:
method_called_event = asyncio.Event()
mocked_silent_call_request.side_effect = (
lambda *args, **kwargs: method_called_event.set()
mocked_silent_call_request.side_effect = lambda *args, **kwargs: (
method_called_event.set()
)
handler_event.clear()

1267
uv.lock generated

File diff suppressed because it is too large Load diff