mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
* Added full support for the Bot API 9.6 * Add support for `managed_bot` updates * Set `description_parse_mode` default to `"parse_mode"` and use `DateTime` for `addition_date` in `PollOption` * Update changelog with features and changes from Bot API 9.6 * Add changelog fragment generator and update poll parameter descriptions
1.9 KiB
1.9 KiB
Bot API Codegen Workflow
How code generation works
aiogram uses butcher (via aiogram-cli) to auto-generate Python files from the Telegram Bot API schema.
Source of truth
.butcher/schema/schema.json— full parsed Bot API schema.butcher/types/<TypeName>/entity.json— parsed entity metadata (DO NOT edit).butcher/methods/<MethodName>/entity.json— parsed method metadata (DO NOT edit).butcher/enums/<EnumName>/entity.json— parsed enum metadata (DO NOT edit).butcher/templates/— Jinja2 templates that produce Python code- YAML alias/override files in
.butcher/types/,.butcher/methods/— edit these for customizations
Generated files (DO NOT hand-edit)
aiogram/types/*.py(exceptbase.py,custom.py,_union.py— framework internals)aiogram/methods/*.py(exceptbase.py)aiogram/enums/*.pyaiogram/client/bot.py(theBotclass shortcuts)aiogram/types/__init__.py,aiogram/methods/__init__.py
Regeneration commands
uv run --extra cli butcher parse # re-parse from API schema
uv run --extra cli butcher refresh # refresh entity JSON from parsed schema
uv run --extra cli butcher apply all # apply templates → generate Python files
Adding a new type/method/shortcut
- Update the
.butcherYAML alias/config file for the entity - Run regeneration (parse → refresh → apply)
- Run lint + mypy + tests
- Commit both the
.butcherconfig changes AND the generated Python files
API version bumps (maintainers)
make update-api args=patch # or minor/major
This runs butcher parse/refresh/apply + version bump scripts that update:
aiogram/__meta__.pyREADME.rstdocs/index.rst
Key constraint
The maintainers enforce: never add types/methods/shortcuts by hand-editing generated files. All changes must go through .butcher config so future regenerations preserve them.