fix(tests): TETRA-2134 — import ModuleType in 3 test files (clear ruff F821) #165
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/TETRA-2134-f821-moduletype"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Investigation của TETRA-2134: 3 lỗi
F821 undefined-nametrong ruff baseline đều là cùng 1 nguyên nhân —-> ModuleTypedùng làm return annotation nhưngModuleTypekhông được import.Kết luận điều tra: KHÔNG phải bug runtime — cả 3 file có
from __future__ import annotations(Python 3.10) nên annotation bị hoãn thành string, không bao giờ eval khi import (đã xác nhận import sạch, exit 0). Nhưng vẫn là F821 thật: tham chiếu tên chưa định nghĩa, phátyping.get_type_hints(), ruff bắt đúng.Fix: thêm
from types import ModuleType(đúng thứ tự isort, trướcfrom unittest.mock) vào:test_asset_categories.pytest_asset_movement_custom_fields.pytest_setup_verification.pyTest Plan
ruff check --select F821 .→ All checks passed (3 → 0)ModuleTypekhông bị F401 (được dùng trong annotation)Ghi chú (baseline triage — đề xuất tách ticket riêng)
Baseline ruff toàn repo hiện ~585 lỗi. Phân loại để đưa về 0 + bật full
ruff checktrong CI:ruff check --fixautofix an toàn.sys, lặt vặt): dọn thủ công từng nhóm.→ Đề xuất follow-up ticket: set ignore-list RUF001/2/3, autofix I001/RUF100, dọn phần còn lại, rồi đổi CI gate từ
--select S110sang fullruff check.🤖 Generated with Claude Code