Skip to content

chore: narrow over-broad mypy and ty error suppressions - #1264

Merged
ogenstad merged 1 commit into
stablefrom
chore/tighten-type-checker-suppressions
Aug 21, 2026
Merged

chore: narrow over-broad mypy and ty error suppressions#1264
ogenstad merged 1 commit into
stablefrom
chore/tighten-type-checker-suppressions

Conversation

@ogenstad

@ogenstad ogenstad commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Why

mypy's misc code was disabled for the whole infrahub_sdk.schema.generated.read module in order to silence a single decorated-property error. misc is 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.utils and infrahub_sdk.ctl.check in 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.
  • Removed three suppressions that match zero violations: mypy arg-type on infrahub_sdk.utils, ty invalid-argument-type on tests/fixtures/**, and ty no-matching-overload on the spec/test_object.py group.
  • Corrected two stale counts in ty comments (node/node.py 9 -> 8, and one group 29 -> 25). Dropped the line numbers on node/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-decorator is 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-file overrides.rules. It reports "All checks passed" while hiding all 1026 latent diagnostics, so the audit needed a temporary pyproject.toml edit instead.

Two module-wide mypy overrides are deliberately left alone, because narrowing them means touching source rather than config:

  • infrahub_sdk.ctl.check disables call-overload module-wide for exactly one error, at infrahub_sdk/ctl/check.py:159.
  • infrahub_sdk.utils disables three codes module-wide, but all seven errors sit in extract_fields at infrahub_sdk/utils.py:297-308.

How to test

uv run invoke lint-code

All three checkers pass: ruff, ty, and mypy (158 source files).

Impact & rollout

  • Backward compatibility: no runtime change; suppression scope only.
  • Config/env changes: pyproject.toml type-checker config only.
  • Deployment notes: safe to merge.

Checklist

  • Tests added/updated: n/a, no runtime code changed
  • Changelog entry: n/a, internal tooling config (labelled ci/skip-changelog)
  • External docs updated: n/a, not user-facing
  • Internal .md docs updated: n/a, no docs reference these settings

Summary by cubic

Tightens type-checker suppressions so they only target the diagnostics that actually fire, preventing unrelated errors from being hidden. Previously mypy disabled misc for the entire generated read module; now it only disables prop-decorator. No runtime changes.

  • Switch infrahub_sdk.schema.generated.read: mypy misc -> prop-decorator (supported since mypy 1.11); confirmed no other diagnostics are suppressed there.
  • Remove dead suppressions: mypy arg-type on infrahub_sdk.utils, ty invalid-argument-type for tests/fixtures/**, and ty no-matching-overload in the spec/test_object.py group.
  • Correct stale ty counts: node/node.py invalid-argument-type 9 -> 8; spec group 29 -> 25. Drop rotted line numbers for node/node.py.
  • Leave two module-wide overrides unchanged: infrahub_sdk.ctl.check (mypy call-overload) and infrahub_sdk.utils (multiple mypy codes) to avoid source changes.
  • Validation: all linters pass (ruff, ty, mypy); run with uv run invoke lint-code.

Written for commit 3518107. Summary will update on new commits.

Review in cubic

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

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

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           
Flag Coverage Δ
integration-tests 39.01% <ø> (ø)
python-3.10 56.97% <ø> (ø)
python-3.11 56.99% <ø> (ø)
python-3.12 56.97% <ø> (ø)
python-3.13 56.99% <ø> (+0.01%) ⬆️
python-3.14 56.99% <ø> (+0.01%) ⬆️
python-filler-3.12 23.68% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Comment thread pyproject.toml
# 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"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here "misc" is a broader version of "prop-decorator", so we're replacing a broad rule with something that's more narrow.

@ogenstad
ogenstad marked this pull request as ready for review August 21, 2026 09:14
@ogenstad
ogenstad requested a review from a team as a code owner August 21, 2026 09:14
@ogenstad
ogenstad merged commit a83d239 into stable Aug 21, 2026
21 checks passed
@ogenstad
ogenstad deleted the chore/tighten-type-checker-suppressions branch August 21, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants