chore(deps): upgrade ty to 0.0.74 - #1321
Draft
ogenstad wants to merge 1 commit into
Draft
Conversation
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.
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
Upgrades the
tydev dependency from0.0.14to0.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:
node.<field>.valueresolves toAttribute | RelationshipManager | RelatedNode, so most dynamic node access in the test suite now trips it.# type: ignore[...]as ty suppressions. ty now wants# ty: ignore[...]or aty:-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.pyandinfrahub_sdk/schema/__init__.py:dict[str, Any]becomesdict[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 dropsdict[str, object]for theRelationshipManagerthatnode.pyalready declares it holds, so.peersresolves without ty having to guess through ahasattrguard.The remaining 351 are recorded as scoped
[[tool.ty.overrides]]entries inpyproject.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_codeentries 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.mdclaimed aty: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"oninfrahub_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.lockis mechanical: ty has no transitive dependencies, so only ty moves.How to test
invoke lint-codepasses clean (mypy: no issues in 159 source files).Unit tests: 1817 passed, 11 failed. Those 11 fail identically on
infrahub-developwithout this branch - they are terminal-width-dependent Rich table assertions in thectlandpytest_pluginsuites. Verified by stashing the branch and re-running; the failure sets are identical.Impact & rollout
Summary by cubic
Upgrades the
tydev 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.# type: ignore[...]as ty suppressions.infrahub_sdk/task/manager.py,infrahub_sdk/schema/__init__.py, andinfrahub_sdk/ctl/object/update.py.[[tool.ty.overrides]]entries inpyproject.tomlwith violation counts; no inline ty suppressions are introduced..agents/rules/code-comments.mdnow points at[[tool.ty.overrides]]as the place for ty violations.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.