chore: narrow over-broad mypy and ty error suppressions - #1264
Merged
Conversation
The generated read models were suppressing all of mypy's `misc` code to silence one decorated-property error. mypy split that diagnostic into its own `prop-decorator` code in 1.11, the version pinned here, so scope the override to it. Verified by removing each suppression and re-running the checker, which also surfaced three dead entries (mypy `arg-type` on utils, ty `invalid-argument-type` on test fixtures, ty `no-matching-overload`) and two stale violation counts.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## stable #1264 +/- ##
=======================================
Coverage 84.16% 84.16%
=======================================
Files 147 147
Lines 13045 13045
Branches 1930 1930
=======================================
Hits 10979 10979
Misses 1503 1503
Partials 563 563
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
ogenstad
commented
Aug 21, 2026
| # does not support decorators on top of ``@property`` and flags it, but pydantic requires this order. | ||
| module = "infrahub_sdk.schema.generated.read" | ||
| disable_error_code = ["misc"] | ||
| disable_error_code = ["prop-decorator"] |
Contributor
Author
There was a problem hiding this comment.
Here "misc" is a broader version of "prop-decorator", so we're replacing a broad rule with something that's more narrow.
ogenstad
marked this pull request as ready for review
August 21, 2026 09:14
gmazoyer
approved these changes
Aug 21, 2026
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.
Why
mypy's
misccode was disabled for the wholeinfrahub_sdk.schema.generated.readmodule in order to silence a single decorated-property error.miscis a catch-all, so that override also hid unrelated real problems (bad overrides, unsupported dynamic base classes, duplicate definitions) in a module that gets regenerated over time.Goal: every type-checker suppression names the narrowest code that actually fires.
Non-goals: this does not attempt to fix any underlying violation, and it leaves the module-wide mypy overrides on
infrahub_sdk.utilsandinfrahub_sdk.ctl.checkin place (see How to review).What changed
No behavioral change: config only, no runtime code touched.
schema.generated.read:misc->prop-decorator. mypy split the decorated-property diagnostic into its own code in 1.11, the version pinned here, so the broad code was never needed.arg-typeoninfrahub_sdk.utils, tyinvalid-argument-typeontests/fixtures/**, and tyno-matching-overloadon thespec/test_object.pygroup.node/node.py9 -> 8, and one group 29 -> 25). Dropped the line numbers onnode/node.py, since all four had rotted: it recorded 776/855/859/862 against actual lines 1024/1294/1298/1301/2259/2525/2527/2529.Confirmed unchanged:
prop-decoratoris the only diagnostic the generated read module produces, so the narrower code loses no coverage. Upgrading mypy would not remove the need for the suppression either, as the error reproduces on 1.11.2, 1.13.0, 1.15.0, 1.18.2, 2.0.0 and 2.3.1.How to review
Each suppression was audited by removing it and re-running the checker, which is the only way these surface, since a config-level ignore is otherwise invisible. One gotcha worth knowing for future audits:
ty check --error <RULE>does not override per-fileoverrides.rules. It reports "All checks passed" while hiding all 1026 latent diagnostics, so the audit needed a temporarypyproject.tomledit instead.Two module-wide mypy overrides are deliberately left alone, because narrowing them means touching source rather than config:
infrahub_sdk.ctl.checkdisablescall-overloadmodule-wide for exactly one error, atinfrahub_sdk/ctl/check.py:159.infrahub_sdk.utilsdisables three codes module-wide, but all seven errors sit inextract_fieldsatinfrahub_sdk/utils.py:297-308.How to test
All three checkers pass: ruff, ty, and mypy (158 source files).
Impact & rollout
pyproject.tomltype-checker config only.Checklist
ci/skip-changelog)Summary by cubic
Tightens type-checker suppressions so they only target the diagnostics that actually fire, preventing unrelated errors from being hidden. Previously
mypydisabledmiscfor the entire generated read module; now it only disablesprop-decorator. No runtime changes.infrahub_sdk.schema.generated.read:mypymisc->prop-decorator(supported sincemypy1.11); confirmed no other diagnostics are suppressed there.mypyarg-typeoninfrahub_sdk.utils,tyinvalid-argument-typefortests/fixtures/**, andtyno-matching-overloadin thespec/test_object.pygroup.tycounts:node/node.pyinvalid-argument-type 9 -> 8; spec group 29 -> 25. Drop rotted line numbers fornode/node.py.infrahub_sdk.ctl.check(mypycall-overload) andinfrahub_sdk.utils(multiplemypycodes) to avoid source changes.ruff,ty,mypy); run with uv run invoke lint-code.Written for commit 3518107. Summary will update on new commits.