chore: complete strict-mypy burn-down (hard gate)#37
Merged
Conversation
Clears all ~24 strict-mypy errors in tango/shapes/ and flips lint.yml's mypy step off continue-on-error. Highlights: - Fix FieldSchema.nested_model annotation to `type | str | None` (it always accepted string model names; the old `type | None` was masking 60+ latent arg-type errors). Widen validate_data / _validate_field_spec model args to `type | str` accordingly. - Replace the lazy-init bool-flag pattern in ShapeParser with an _ensure_registry() helper so the registry narrows to non-None. - Remove two provably-dead `elif field_spec.is_wildcard:` branches (wildcards already `continue` at the top of the loop) and the now-orphaned _parse_nested_wildcard helper. Behavior-preserving. - Misc: cast Any->type/str returns, annotate field_type as Any, best_score as float, builtins.type disambiguation in FieldSchema. No runtime behavior change; 420 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the strict-
mypyburn-down fortango/shapes/(the ~24/28 pre-existing errorslint.ymltracked) and flips the mypy CI step offcontinue-on-error— it's now a hard gate.tango/type-checks cleanly under strict mypy.What changed
FieldSchema.nested_modelannotation fixed totype | str | None. It always accepted string model names from the explicit schemas; the oldtype | Nonewas a genuine bug that masked 60+ latentarg-typeerrors (surfaced the moment the shadowed-typeissue was fixed).ModelFactory.validate_dataandShapeParser._validate_field_specnow accepttype | strfor the model arg to match.ShapeParserregistry: replaced the lazy-init bool-flag pattern with an_ensure_registry()helper so the registry narrows to non-None(kills fiveunion-attrerrors and the latentAttributeErrorrisk they implied).elif field_spec.is_wildcard:branches (TypeGenerator.generate_type,ModelFactory.create_instance) plus the now-orphaned_parse_nested_wildcardhelper. Wildcard field specs are fully handled by the top-of-loop branch thatcontinues before these are ever reached, so removal is behavior-preserving.castonAny→type/strreturns,field_type: Any,best_score = 0.0,builtins.typeto disambiguate the shadowedtypefield, one scoped# type: ignore[unreachable]on a defensiveisinstance(data, dict)guard.Testing
uv run mypy tango/→ clean (0 errors).ruff format --check+ruff check→ clean.420 passed, 1 skipped(non-production suite). No runtime behavior change.Note for reviewers
The dead nested-wildcard branches looked like they handled
recipient(*), but they never executed (the loopcontinues on any wildcard field first). If nested-wildcard expansion is actually desired, that's a separate, pre-existing bug — this PR doesn't change current behavior.~ Mark