Repository navigation
chore: fix most ty errors behind the infrahub_sdk/node/node.py override - #1552
Merged
Merged
Conversation
Read the file object checksum through `_get_attribute`, narrow the schema to `NodeSchemaAPI` before reading `hierarchy`, and use `getattr` with a default in `is_resource_pool`. This removes the `invalid-argument-type` and `unsupported-operator` ty overrides for node.py and leaves 2 `unresolved-attribute` violations in `is_ip_prefix` and `is_ip_address`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
e89843e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4447cacf.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://nisse-ihs-321.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## develop #1552 +/- ##
===========================================
- Coverage 87.91% 87.88% -0.04%
===========================================
Files 157 157
Lines 15851 15663 -188
Branches 2162 2114 -48
===========================================
- Hits 13936 13766 -170
Misses 1336 1336
+ Partials 579 561 -18
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
ogenstad
marked this pull request as ready for review
November 26, 2026 07:25
gmazoyer
approved these changes
Nov 26, 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
The
[[tool.ty.overrides]]section forinfrahub_sdk/node/node.pyturned offinvalid-argument-type,unresolved-attributeandunsupported-operator, so ty did not report errors in that file. Most of those violations can be fixed without changing what the code does.Non-goals:
is_ip_prefixandis_ip_addressare unchanged. Fixing them would change what they return for a generic schema.What changed
No behaviour changes.
download_file,matches_local_checksumandupload_if_changed(async and sync), the checksum is now read withself._get_attribute("checksum"), which is typed asAttribute. The# type: ignore[union-attr]comments on the.valuereads are removed. Both__getattr__and_get_attributereturn the same object from_attribute_data, andFieldNotLoadedErroris still raised when.valueis read.is_resource_poolnow returns"CoreResourcePool" in getattr(self._schema, "inherit_from", []).isinstance(self._schema, NodeSchemaAPI)to gethierarchy_kind. The method returns early whenhierarchy_kindisNone, andhierarchy_kindis passed toschema.get(kind=...)and_build_hierarchy_query_data(peer_kind=...). The type-ignore comments on those lines are removed.pyproject.toml, the node.py section no longer ignoresinvalid-argument-typeandunsupported-operator. Theunresolved-attributecomment now says 2 violations, inis_ip_prefixandis_ip_address.How to review
hierarchy_kind is Noneearly return matches the existing_hierarchy_supportcheck.supports_hierarchyis true only for aNodeSchemaAPIwhosehierarchyis set.unresolved-attributeerrors, one each inis_ip_prefixandis_ip_address.How to test
uv run ty check . uv run mypy --show-error-codes infrahub_sdk uv run invoke format lint-code uv run pytest tests/unit/sdk/test_node.py tests/unit/sdk/test_file_object.py tests/unit/sdk/test_hierarchical_nodes.py tests/unit/sdk/test_node_only_access.pyAll of these passed locally. The test run reported 585 passed.
Impact & rollout
Checklist
uv run towncrier create ...)No changelog fragment was added because users cannot see this change.
🤖 Generated with Claude Code
Jira: IHS-321