Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Dec 30, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved stability when handling schema inheritance with missing or null values.
  • Chores

    • Enhanced type checking enforcement in development toolchain.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 30, 2025

Walkthrough

This pull request modifies the get_all_kinds() method in the InfrahubNodeBase class to use safer attribute access. The implementation replaces a hasattr() check with a getattr() call using a walrus operator, improving null-safety when accessing the inherit_from attribute on the schema object. Additionally, the pull request removes the ignore rule for the unsupported-operator type-checking rule in the project configuration, enabling the static type checker to enforce this rule across the codebase.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix unsupported operator on MainSchemaTypes' is directly related to the main change: removing the ignore for the unsupported-operator rule in pyproject.toml to enforce type checking on MainSchemaTypes.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9e2c560
Status: ✅  Deploy successful!
Preview URL: https://d2dcb767.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-fix-unsupported-operator.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@                 Coverage Diff                  @@
##           infrahub-develop     #721      +/-   ##
====================================================
+ Coverage             76.28%   76.30%   +0.02%     
====================================================
  Files                   114      114              
  Lines                  9830     9830              
  Branches               1508     1508              
====================================================
+ Hits                   7499     7501       +2     
+ Misses                 1837     1836       -1     
+ Partials                494      493       -1     
Flag Coverage Δ
integration-tests 34.44% <100.00%> (+0.02%) ⬆️
python-3.10 50.17% <100.00%> (ø)
python-3.11 50.19% <100.00%> (+0.04%) ⬆️
python-3.12 50.15% <100.00%> (ø)
python-3.13 50.15% <100.00%> (ø)
python-3.14 51.82% <100.00%> (+0.04%) ⬆️
python-filler-3.12 24.01% <0.00%> (ø)

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 79.74% <100.00%> (+0.21%) ⬆️
🚀 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 December 30, 2025 09:11
@ogenstad ogenstad requested a review from a team December 30, 2025 09:12
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
infrahub_sdk/node/node.py (1)

207-214: Consider applying the same safer pattern to similar checks.

For consistency with the fix in get_all_kinds(), you might consider updating the other inherit_from checks to use the same getattr pattern:

# Line 207
inherit_from = getattr(self._schema, "inherit_from", [])
return self.get_kind() == builtin_ipprefix_kind or builtin_ipprefix_kind in inherit_from

# Line 211
inherit_from = getattr(self._schema, "inherit_from", [])
return self.get_kind() == builtin_ipaddress_kind or builtin_ipaddress_kind in inherit_from

# Line 214
inherit_from = getattr(self._schema, "inherit_from", [])
return "CoreResourcePool" in inherit_from

This would eliminate the remaining type: ignore[union-attr] comments and make the attribute access pattern consistent across the class.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f7ee7d and 9e2c560.

📒 Files selected for processing (2)
  • infrahub_sdk/node/node.py
  • pyproject.toml
💤 Files with no reviewable changes (1)
  • pyproject.toml
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use type hints on all function signatures
Never mix async/sync inappropriately
Never bypass type checking without justification

Files:

  • infrahub_sdk/node/node.py
infrahub_sdk/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Follow async/sync dual pattern for new features in the Python SDK

Files:

  • infrahub_sdk/node/node.py
🧬 Code graph analysis (1)
infrahub_sdk/node/node.py (1)
infrahub_sdk/node/related_node.py (1)
  • kind (132-135)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
infrahub_sdk/node/node.py (1)

200-203: LGTM! Safer attribute access with walrus operator.

The implementation correctly uses getattr with a default value and the walrus operator to safely handle cases where inherit_from might be missing, None, or an empty list. This eliminates the type-checking issue that required ignoring the unsupported-operator rule.

@ogenstad ogenstad merged commit 9e5ce80 into infrahub-develop Dec 30, 2025
21 checks passed
@ogenstad ogenstad deleted the pog-fix-unsupported-operator branch December 30, 2025 10:21
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.

3 participants