From d36aa57e2fca09b8d3e1062a52ddb161f93ac601 Mon Sep 17 00:00:00 2001 From: Saltaferis Dimitrios Date: Thu, 6 Aug 2026 11:09:20 +0000 Subject: [PATCH] refactor(sdk): type group members access via _get_relationship_many MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../+query-groups-typed-members-accessor.housekeeping.md | 1 + infrahub_sdk/query_groups.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelog/+query-groups-typed-members-accessor.housekeeping.md diff --git a/changelog/+query-groups-typed-members-accessor.housekeeping.md b/changelog/+query-groups-typed-members-accessor.housekeeping.md new file mode 100644 index 000000000..0e6eeeca2 --- /dev/null +++ b/changelog/+query-groups-typed-members-accessor.housekeeping.md @@ -0,0 +1 @@ +Routed the two remaining `existing_group.members.peer_ids` accesses in `infrahub_sdk/query_groups.py` through the typed `_get_relationship_many(name="members")` accessor, removing the last two `# type: ignore[union-attr]` suppressions in that module. Internal typing hygiene with no behavioural change. diff --git a/infrahub_sdk/query_groups.py b/infrahub_sdk/query_groups.py index cc7faebd1..3fcde3461 100644 --- a/infrahub_sdk/query_groups.py +++ b/infrahub_sdk/query_groups.py @@ -175,7 +175,9 @@ async def update_group(self) -> None: return # Calculate how many nodes should be deleted - self.unused_member_ids = list(set(existing_group.members.peer_ids) - set(members)) # type: ignore[union-attr] + self.unused_member_ids = list( + set(existing_group._get_relationship_many(name="members").peer_ids) - set(members) + ) if not self.delete_unused_nodes: return @@ -267,7 +269,9 @@ def update_group(self) -> None: return # Calculate how many nodes should be deleted - self.unused_member_ids = list(set(existing_group.members.peer_ids) - set(members)) # type: ignore[union-attr] + self.unused_member_ids = list( + set(existing_group._get_relationship_many(name="members").peer_ids) - set(members) + ) if not self.delete_unused_nodes: return