Skip to content

chore(deps): upgrade ty to 0.0.74 - #1321

Draft
ogenstad wants to merge 1 commit into
infrahub-developfrom
chore/upgrade-ty-0.0.74
Draft

chore(deps): upgrade ty to 0.0.74#1321
ogenstad wants to merge 1 commit into
infrahub-developfrom
chore/upgrade-ty-0.0.74

Conversation

@ogenstad

@ogenstad ogenstad commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Why

Upgrades the ty dev dependency from 0.0.14 to 0.0.74 - 60 releases of type-checker improvements.

This is a tooling-only change, but unlike the recent mypy bump it is not mechanical. No intermediate version lands clean: 0.0.15 already reports 44 diagnostics, and 0.0.74 reports 357. Two upstream changes account for nearly all of them:

  • 0.0.17 began erroring when an attribute is missing on any member of a union. This is the bulk of the noise - node.<field>.value resolves to Attribute | RelationshipManager | RelatedNode, so most dynamic node access in the test suite now trips it.
  • 0.0.25 (flagged upstream as a breaking change) stopped reading bare mypy codes in # type: ignore[...] as ty suppressions. ty now wants # ty: ignore[...] or a ty:-prefixed code inside the brackets.

Non-goals: this PR intentionally does not redesign InfrahubNode.__getattr__ to stop returning a three-way union. That would clear roughly 275 of the 357 diagnostics at source, but it changes the SDK's public typing surface and belongs in its own change.

What changed

Six diagnostics were genuine imprecision and are fixed rather than suppressed:

  • infrahub_sdk/task/manager.py and infrahub_sdk/schema/__init__.py: dict[str, Any] becomes dict[str, dict[str, Any]]. ty narrows a declaration to the shape of the literal assigned to it and then rejects later writes to sibling keys. The nested annotation is simply more accurate, and mypy agrees.
  • infrahub_sdk/ctl/object/update.py: the cardinality-many relationship store drops dict[str, object] for the RelationshipManager that node.py already declares it holds, so .peers resolves without ty having to guess through a hasattr guard.

The remaining 351 are recorded as scoped [[tool.ty.overrides]] entries in pyproject.toml, annotated with violation counts and merged into the existing per-file blocks, matching how this repo already tracks incremental type debt.

Two of those overrides mirror module-level [[tool.mypy.overrides]] disable_error_code entries the repo already carries for the identical errors (infrahub_sdk/ctl/check.py / call-overload, infrahub_sdk/utils.py / return-value), and are commented as such.

No inline ty suppressions are introduced. .agents/rules/code-comments.md claimed a ty: comment "suppresses nothing and is dead" - true under 0.0.14, false since 0.0.25. The rule is corrected and now points at [[tool.ty.overrides]] as the place ty violations belong.

What stayed the same: no runtime code paths, no public API, no behavior. Three annotation changes and one type-only import.

How to review

The substance is in pyproject.toml. The three source files are annotation-only and self-contained.

Worth extra scrutiny: unresolved-attribute = "ignore" on infrahub_sdk/node/node.py (22 violations) is the broadest override added, and that rule does catch genuine typos. Mitigating context - all 61 production diagnostics moved into config were already suppressed inline for mypy on the exact same lines, so this concedes no signal the repo had not already conceded.

uv.lock is mechanical: ty has no transitive dependencies, so only ty moves.

How to test

uv sync --all-groups --all-extras
uv run ty check .            # All checks passed!
uv run invoke lint-code      # ruff + ty + mypy all pass
uv run pytest tests/unit/

invoke lint-code passes clean (mypy: no issues in 159 source files).

Unit tests: 1817 passed, 11 failed. Those 11 fail identically on infrahub-develop without this branch - they are terminal-width-dependent Rich table assertions in the ctl and pytest_plugin suites. Verified by stashing the branch and re-running; the failure sets are identical.

Impact & rollout

  • Backward compatibility: No public API or behavior changes.
  • Config/env changes: None beyond the dev dependency pin and the ty rule configuration.
  • Deployment notes: Safe to deploy - dev-tooling change only.

Summary by cubic

Upgrades the ty dev dependency from 0.0.14 to 0.0.74 and gets the type checker passing cleanly again, with no runtime, public API, or behavior changes.

  • Two upstream changes account for nearly all of the 357 new diagnostics: 0.0.17 errors when an attribute is missing on any union member, and 0.0.25 stopped reading bare mypy codes in # type: ignore[...] as ty suppressions.
  • Six diagnostics were genuine imprecision and are fixed with more accurate annotations in infrahub_sdk/task/manager.py, infrahub_sdk/schema/__init__.py, and infrahub_sdk/ctl/object/update.py.
  • The remaining 351 are recorded as scoped [[tool.ty.overrides]] entries in pyproject.toml with violation counts; no inline ty suppressions are introduced.
  • .agents/rules/code-comments.md now points at [[tool.ty.overrides]] as the place for ty violations.
  • The 11 unit test failures are pre-existing on infrahub-develop (terminal-width-dependent Rich table assertions) and are identical with or without this branch.

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

Review in cubic

ty 0.0.14 was 60 releases behind, and no intermediate version lands clean --
even 0.0.15 reports 44 diagnostics. Two upstream changes account for nearly all
of the 357: 0.0.17 began erroring when an attribute is missing on any member of
a union, and 0.0.25 stopped reading bare mypy codes in `# type: ignore[...]` as
ty suppressions.

Six of those diagnostics were genuine imprecision and are fixed rather than
suppressed. `dict[str, Any]` in the task manager and schema dropdown mutations
becomes `dict[str, dict[str, Any]]`, since ty narrows a declaration to the
assigned literal's shape and then rejects writes to sibling keys. The CLI's
relationship store drops `dict[str, object]` for the `RelationshipManager` that
node.py already declares it holds.

The rest are recorded as scoped `[[tool.ty.overrides]]` entries with violation
counts, matching how the repo already tracks incremental type debt. Every
production diagnostic moved into config was already suppressed inline for mypy
on the same line, so no signal is lost. No inline ty suppressions are
introduced; the comment rule is updated to say so and to point at the config
instead.

Tooling-only: no runtime or public-API impact.
@ogenstad ogenstad added type/housekeeping Maintenance task ci/skip-changelog Don't include this PR in the changelog labels Sep 4, 2026

@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 6 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/skip-changelog Don't include this PR in the changelog type/housekeeping Maintenance task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant