Skip to main content

fix-codegen-imports

Fix missing imports in butcher-generated aiogram code (F821 "Undefined name" after `butcher apply`). Use when ruff reports undefined names in aiogram/enums, aiogram/types or aiogram/methods after a Bot API codegen run, or when the user says "fix codegen imports".

소스 정보

저장소
aiogram/aiogram
최근 소스 활동
2026년 8월 18일 15:34
감지된 SKILL.md 언어
영어
스타
5,893
포크
974

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
fix-codegen-imports
description
Fix missing imports in butcher-generated aiogram code (F821 "Undefined name" after `butcher apply`). Use when ruff reports undefined names in aiogram/enums, aiogram/types or aiogram/methods after a Bot API codegen run, or when the user says "fix codegen imports".
# 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 1. List the offenders: ```bash rtk ruff check --preview --output-format=concise aiogram examples ``` Only `F821 Undefined name` findings are in scope. Anything else is a real bug — report it, don't patch it. 2. 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 | |---|---|---| | `Enum` in `aiogram/enums/*.py` | `from enum import Enum` as the first line | `aiogram/enums/chat_action.py` | | An enum in `aiogram/types/*.py` or `aiogram/methods/*.py` | `from ..enums import <Name>`, placed above the `from .` imports | `aiogram/types/input_paid_media_photo.py` | | A type in `aiogram/types/*.py` | `from .<snake_case_module> import <Name>` | any sibling type | If the module has annotations referencing types only imported under `TYPE_CHECKING`, it also needs `from __future__ import annotations` as the first line — generated modules that quote forward refs all have it. 3. Verify: ```bash 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.
GitHub에서 보기