Skip to content

chore: fix most ty errors behind the infrahub_sdk/node/node.py override - #1552

Merged
ogenstad merged 1 commit into
developfrom
nisse/IHS-321
Nov 26, 2026
Merged

ogenstad merged 1 commit into
developfrom
nisse/IHS-321

Conversation

@ogenstad

@ogenstad ogenstad commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

This pull request was written by nisse, an AI agent, and opened with the GitHub account of the person who runs it. That person reviews it before marking it ready for review.

Why

The [[tool.ty.overrides]] section for infrahub_sdk/node/node.py turned off invalid-argument-type, unresolved-attribute and unsupported-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_prefix and is_ip_address are unchanged. Fixing them would change what they return for a generic schema.

What changed

No behaviour changes.

  • In download_file, matches_local_checksum and upload_if_changed (async and sync), the checksum is now read with self._get_attribute("checksum"), which is typed as Attribute. The # type: ignore[union-attr] comments on the .value reads are removed. Both __getattr__ and _get_attribute return the same object from _attribute_data, and FieldNotLoadedError is still raised when .value is read.
  • is_resource_pool now returns "CoreResourcePool" in getattr(self._schema, "inherit_from", []).
  • In both hierarchy query methods, the schema is narrowed with isinstance(self._schema, NodeSchemaAPI) to get hierarchy_kind. The method returns early when hierarchy_kind is None, and hierarchy_kind is passed to schema.get(kind=...) and _build_hierarchy_query_data(peer_kind=...). The type-ignore comments on those lines are removed.
  • In pyproject.toml, the node.py section no longer ignores invalid-argument-type and unsupported-operator. The unresolved-attribute comment now says 2 violations, in is_ip_prefix and is_ip_address.

How to review

  • Check that the new hierarchy_kind is None early return matches the existing _hierarchy_support check. supports_hierarchy is true only for a NodeSchemaAPI whose hierarchy is set.
  • Check that the remaining override comment is accurate. With the override removed, ty reported 2 unresolved-attribute errors, one each in is_ip_prefix and is_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.py

All of these passed locally. The test run reported 585 passed.

Impact & rollout

  • Backward compatibility: No changes to the public API or to behaviour.

Checklist

  • Tests added/updated
  • Changelog entry added (uv run towncrier create ...)
  • External docs updated (if user-facing or ops-facing change)
  • Internal .md docs updated (internal knowledge and AI code tools knowledge)

No changelog fragment was added because users cannot see this change.

🤖 Generated with Claude Code

Jira: IHS-321

View guided diff Turn on auto-fix

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>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

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

View logs

@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

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     
Flag Coverage Δ
integration-tests 42.99% <28.00%> (+0.25%) ⬆️
python-3.10 63.05% <100.00%> (+0.38%) ⬆️
python-3.11 63.04% <100.00%> (+0.37%) ⬆️
python-3.12 63.05% <100.00%> (+0.38%) ⬆️
python-3.13 63.05% <100.00%> (+0.38%) ⬆️
python-3.14 63.05% <100.00%> (+0.38%) ⬆️
python-3.15 63.05% <100.00%> (+0.40%) ⬆️
python-filler-3.12 23.04% <0.00%> (-0.55%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/node/node.py 90.21% <100.00%> (+0.01%) ⬆️

... and 3 files with indirect coverage changes

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

@ogenstad
ogenstad marked this pull request as ready for review November 26, 2026 07:25
@ogenstad
ogenstad requested a review from a team as a code owner November 26, 2026 07:25

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

View guided diff | Turn on auto-fix | Re-trigger cubic

@ogenstad
ogenstad merged commit 7f1c10d into develop Nov 26, 2026
33 checks passed
@ogenstad
ogenstad deleted the nisse/IHS-321 branch November 26, 2026 08:38
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