IHS-183: Fix typing errors for protocols#763
Conversation
WalkthroughThis pull request converts Protocol-based type definitions to concrete base classes and updates related type handling throughout the SDK. Changes include removing 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying infrahub-sdk-python with
|
| Latest commit: |
810a5c4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://62bebc14.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://re-sb-20260119-fix-typing-fo.infrahub-sdk-python.pages.dev |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## develop #763 +/- ##
===========================================
- Coverage 82.02% 81.85% -0.18%
===========================================
Files 135 135
Lines 11841 11665 -176
Branches 1762 1761 -1
===========================================
- Hits 9713 9548 -165
+ Misses 1576 1571 -5
+ Partials 552 546 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 5 files with indirect coverage changes 🚀 New features to boost your workflow:
|
6c5bd98 to
99ce971
Compare
There was a problem hiding this comment.
1 issue found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="infrahub_sdk/node/related_node.py">
<violation number="1" location="infrahub_sdk/node/related_node.py:50">
P2: `hasattr(data, "_schema")` is an overly broad peer check and can misclassify non-node objects, causing runtime attribute errors.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| self._peer = data | ||
| # Check for InfrahubNodeBase instances using duck-typing (_schema attribute) | ||
| # to avoid circular imports, or CoreNodeBase instances | ||
| if isinstance(data, CoreNodeBase) or hasattr(data, "_schema"): |
There was a problem hiding this comment.
P2: hasattr(data, "_schema") is an overly broad peer check and can misclassify non-node objects, causing runtime attribute errors.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At infrahub_sdk/node/related_node.py, line 50:
<comment>`hasattr(data, "_schema")` is an overly broad peer check and can misclassify non-node objects, causing runtime attribute errors.</comment>
<file context>
@@ -45,8 +45,10 @@ def __init__(self, branch: str, schema: RelationshipSchemaAPI, data: Any | dict,
- self._peer = data
+ # Check for InfrahubNodeBase instances using duck-typing (_schema attribute)
+ # to avoid circular imports, or CoreNodeBase instances
+ if isinstance(data, CoreNodeBase) or hasattr(data, "_schema"):
+ self._peer = cast("InfrahubNodeBase | CoreNodeBase", data)
for prop in self._properties:
</file context>
|
Rebased and pushed some changes to account for a new issue with numberpools also ran a test pipeline for this against infrahub, but based on the |
Fixes #697
Replace protocols with concrete classes to address type-abstract mypy errors
Summary by CodeRabbit
Refactor
Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.