3 Commits
Author SHA1 Message Date
rookiestar28andClaude Opus 5 ac9fbeec8d refactor(quality): modernize annotations in the three best-covered packages
R250 tranche 1. The static-analysis baseline is reduced by fixing code, not by
raising pins, in the packages where a mechanical rewrite is best protected by
tests: models (92.7% covered), nodes (90.1%) and scripts (80.0%). The two worst
covered packages, connector (57.1%) and api (60.7%), are deferred, and no path
in the tranche matches a canonical high-risk pattern.

Ruff UP006/UP035/UP045 across 17 files removes 146 findings: PEP 585 builtin
generics, PEP 604 unions, and the deprecated typing imports they consume. The
autofix was scoped to an explicit file list and rule list, never to a directory
or the repository, and the whole diff was reviewed.

Those rewrites orphan 23 typing imports, so "remove no imports" was not
available: leaving them would be new debt the exact-match ratchet rejects. The
rule applied instead is narrow and uniformly evidenced - remove an unused import
only when it is a typing-vocabulary name from typing or the collections.abc
target UP035 relocates to. Neither module has import side effects and no file in
the tranche declares __all__, so no such name can be a compatibility re-export.
That removed 37 imports, the 23 orphans plus 14 already-dead ones. Six unused
imports that need real analysis are untouched: a possible re-export in
models.schemas, two bare sys/os imports, a name imported out of a test module,
and unittest.mock.patch.

mypy strictness advances by exactly two packages. models.* and nodes.* now set
disallow_untyped_defs through a scoped override; the global default stays false.
The measured cost was 11 missing annotations, all added here.

models/schemas.py filters caller payloads through cls.__annotations__ and the
node classes are introspected by the ComfyUI host, so the pins for both went in
before the rewrite: exact annotation-key tuples for all five dataclasses,
from_dict filtering, asdict/JSON round-trips, the frozen INPUT_TYPES /
RETURN_TYPES / FUNCTION / CATEGORY surface, and a load check for every tranche
script. All 11 passed before the rewrite and pass unchanged after it.

Ruff also had to reach for builtins.dict in GenerationParams.from_dict, because
that class defines a dict() method that shadows the builtin inside the class
body by the time the later annotation is evaluated. That is correct and the
alternative would rename a public method.

Baseline: 1465 -> 1395 fingerprints, 3566 -> 3406 findings. The written diff
removes UP006 93, UP035 33, UP045 20 and F401 14, adds nothing, and touches no
path outside the 17 tranche files.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DJVFcBRvDopwG5qwW4ThNt
2026-09-06 15:59:43 +08:00
rookiestar28 d641c04bde chore: apply auto formated file 2026-03-12 18:46:00 +08:00
rookiestar28 91423bc320 chore: guard generated OpenAPI spec sync in pre-commit and pre-push 2026-03-12 18:43:49 +08:00