refactor(sdk): type group members access via _get_relationship_many - #1227
Open
saltas888 wants to merge 1 commit into
Open
refactor(sdk): type group members access via _get_relationship_many#1227saltas888 wants to merge 1 commit into
saltas888 wants to merge 1 commit into
Conversation
The two `existing_group.members.peer_ids` sites in query_groups.py each carried a `# type: ignore[union-attr]` because `.members` is typed as a union that includes `None`. PR #412 introduced `_get_relationship_many(name="members")` precisely to type this access and applied it at the two `.peers` call sites, but the `.peer_ids` sites were left behind. Route both through the typed accessor and drop the suppressions. `peer_ids` is defined on `RelationshipManagerBase`, so it resolves for both the async `RelationshipManager` and the sync `RelationshipManagerSync` — a like-for-like substitution with no behavioural change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
d36aa57
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c4638dad.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://pha-inbox-28.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## develop #1227 +/- ##
===========================================
- Coverage 85.21% 82.97% -2.24%
===========================================
Files 146 141 -5
Lines 15605 12614 -2991
Branches 2631 1909 -722
===========================================
- Hits 13298 10467 -2831
+ Misses 1642 1577 -65
+ Partials 665 570 -95
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 30 files with indirect coverage changes 🚀 New features to boost your workflow:
|
ogenstad
approved these changes
Aug 6, 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
infrahub_sdk/query_groups.pyhad twoexisting_group.members.peer_idsaccesses, each silenced with# type: ignore[union-attr]because.membersis typed as a union that includesNone.PR #412 introduced
_get_relationship_many(name="members")specifically to type this access, and applied it at the two.peerscall sites (L108 / L206) — but the two.peer_idssites (L178 / L270) were left behind with their suppressions. This finishes that migration.Non-goals: no change to grouping behaviour, no public API change, no new accessor added (none was needed — see below).
Jira: INBOX-28
Source: #412 (comment)
What changed
Behavioral changes: none. This is a like-for-like typing substitution.
existing_group.members.peer_idssites throughexisting_group._get_relationship_many(name="members").peer_ids.# type: ignore[union-attr]suppressions — the last two in this module.Implementation note: the card left open whether a
peer_idshelper would need adding. It does not —peer_idsis defined onRelationshipManagerBase(infrahub_sdk/node/relationship.py:61), so it resolves for both the asyncRelationshipManagerand the syncRelationshipManagerSyncthat_get_relationship_manyreturns. Both the async (InfrahubGroupContext) and sync (InfrahubGroupContextSync) twins get the identical treatment, so the twins stay in sync.What stayed the same: no schema changes, no API contract changes, no dependency changes, no CI changes, no generated files. The diff is 2 files: one source file and one changelog fragment.
How to review
The whole change is 6 lines in one file. The only thing worth checking is that
peer_idsis genuinely available on the base class (linked above) so the async and sync paths are both really typed rather than newly ignored.How to test
Results on this branch:
mypy --show-error-codes infrahub_sdk/ruff check .ruff format --check .pytest tests/unit/sdk/test_group_context.pypytest tests/unit/sdk/The 3 failures are in
tests/unit/sdk/test_schema.py(test_display_schema_load_errors_details_*) and are pre-existing and unrelated — they assert on plain strings while Rich emits ANSI colour codes in this environment. Verified by stashing this change and re-running on the clean base commit: the same 3 fail identically there.ty check .reports 48unresolved-importdiagnostics in this environment only, because thetestsdependency group could not be installed locally (ruamel-yaml-clibhas no cp314 wheel and needsPython.h, which isn't present on this machine). None of them are inquery_groups.py. CI installs the full group, so this is a local environment artifact.Impact & rollout
Checklist
mypyis the verifier. Existingtest_group_context.pycoverage exercises both changed code paths.changelog/+query-groups-typed-members-accessor.housekeeping.md)🤖 Generated with Claude Code
Summary by cubic
Use the typed
existing_group._get_relationship_many(name="members").peer_idsininfrahub_sdk/query_groups.pyto replace the lastexisting_group.members.peer_idsusages, removing two# type: ignore[union-attr]suppressions. No behavior change; fulfills INBOX-28.Written for commit d36aa57. Summary will update on new commits.