Fix codegen imports
butcher apply sometimes emits modules that reference a name it never imported
(usually a new enum, or Enum itself). Ruff catches all of them as F821.
Steps
List the offenders:
rtk ruff check --preview --output-format=concise aiogram examplesOnly
F821 Undefined namefindings are in scope. Anything else is a real bug — report it, don't patch it.For each undefined name, copy the import from a sibling module that already uses the same kind of symbol — do not invent a new style:
Undefined name Fix Reference file Enuminaiogram/enums/*.pyfrom enum import Enumas the first lineaiogram/enums/chat_action.pyAn enum in aiogram/types/*.pyoraiogram/methods/*.pyfrom ..enums import <Name>, placed above thefrom .importsaiogram/types/input_paid_media_photo.pyA type in aiogram/types/*.pyfrom .<snake_case_module> import <Name>any sibling type If the module has annotations referencing types only imported under
TYPE_CHECKING, it also needsfrom __future__ import annotationsas the first line — generated modules that quote forward refs all have it.Verify:
rtk ruff format aiogram rtk ruff check --preview aiogram examples rtk mypy aiogram
Follow-up
These files are generated. A hand-fix survives only until the next
butcher apply all. After the branch is green, tell the user the durable fix
belongs in .butcher (template / entity config for the symbol whose import was
dropped) so regeneration stops losing it.