Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Sep 10, 2025

Summary by CodeRabbit

  • Chores
    • Tightened linting rules to enforce return type annotations for private and special methods, improving code consistency and quality.
  • Tests
    • Added explicit return type annotations in test helpers to align with stricter linting; no runtime behavior changes.

@coderabbitai
Copy link

coderabbitai bot commented Sep 10, 2025

Walkthrough

  • Updated pyproject.toml to stop ignoring Ruff rules ANN202 and ANN204 for infrahub_sdk//*.py and tests//*.py.
  • Added explicit return type annotations (-> None) to validate methods in IFCheckAsync and IFCheckSync within tests/unit/sdk/checks/test_checks.py.
  • Added a -> None return type annotation to the local helper function mock_init in tests/unit/sdk/test_repository.py.
  • No changes to exported/public entities beyond type annotations in test classes; runtime behavior unchanged.

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 return types” directly reflects the primary change in this PR, which is the addition and enforcement of missing return type annotations across the codebase. It is concise and clear, focusing on the core intent without extraneous detail, and a teammate reviewing history will understand that return type corrections are the main point of this changeset.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pog-test-return-types

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: 90f7be1
Status: ✅  Deploy successful!
Preview URL: https://7b614792.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-test-return-types.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Sep 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@             Coverage Diff             @@
##           develop     #541      +/-   ##
===========================================
- Coverage    75.94%   75.84%   -0.11%     
===========================================
  Files          100      100              
  Lines         9329     8868     -461     
  Branches      1832     1737      -95     
===========================================
- Hits          7085     6726     -359     
+ Misses        1754     1668      -86     
+ Partials       490      474      -16     
Flag Coverage Δ
integration-tests 34.83% <ø> (-1.41%) ⬇️
python-3.10 48.30% <ø> (-1.34%) ⬇️
python-3.11 48.30% <ø> (-1.34%) ⬇️
python-3.12 48.30% <ø> (-1.29%) ⬇️
python-3.13 48.30% <ø> (-1.32%) ⬇️
python-3.9 46.98% <ø> (-1.07%) ⬇️
python-filler-3.12 25.05% <ø> (+0.82%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 8 files with indirect coverage changes

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

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)
tests/unit/sdk/test_repository.py (1)

53-55: **Return type added correctly; optional: type *args/kwargs to drop noqa.

-> None is correct for the sentinel stub. If you want to avoid # noqa: ANN002, ANN003, annotate the variadics:

-    def mock_init(*args, **kwargs) -> None:  # noqa: ANN002, ANN003
+    def mock_init(*args: Any, **kwargs: Any) -> None:

And add:

from typing import Any
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c7922f and 90f7be1.

📒 Files selected for processing (3)
  • pyproject.toml (0 hunks)
  • tests/unit/sdk/checks/test_checks.py (1 hunks)
  • tests/unit/sdk/test_repository.py (1 hunks)
💤 Files with no reviewable changes (1)
  • pyproject.toml
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

When implementing Infrahub checks, subclass InfrahubCheck and override validate(data); do not implement or rely on a check() method

Files:

  • tests/unit/sdk/test_repository.py
  • tests/unit/sdk/checks/test_checks.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Place and write unit tests under tests/unit/ (isolated component tests)

Files:

  • tests/unit/sdk/test_repository.py
  • tests/unit/sdk/checks/test_checks.py
tests/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use the custom pytest plugin (infrahub_sdk.pytest_plugin) fixtures for clients, configuration, and Infrahub-specific testing

Files:

  • tests/unit/sdk/test_repository.py
  • tests/unit/sdk/checks/test_checks.py
🧠 Learnings (1)
📚 Learning: 2025-08-24T13:35:12.998Z
Learnt from: CR
PR: opsmill/infrahub-sdk-python#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T13:35:12.998Z
Learning: Applies to **/*.py : When implementing Infrahub checks, subclass InfrahubCheck and override validate(data); do not implement or rely on a check() method

Applied to files:

  • tests/unit/sdk/checks/test_checks.py
🧬 Code graph analysis (1)
tests/unit/sdk/checks/test_checks.py (1)
infrahub_sdk/checks.py (1)
  • InfrahubCheck (33-175)
⏰ 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). (4)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: integration-tests-latest-infrahub
🔇 Additional comments (2)
tests/unit/sdk/checks/test_checks.py (2)

49-51: Async validate return type matches base signature.

async def validate(... ) -> None aligns with InfrahubCheck.validate and project guidelines. LGTM.


55-57: Sync validate return type matches base signature.

def validate(... ) -> None is consistent and correct. LGTM.

@ogenstad ogenstad requested a review from a team September 10, 2025 18:34
@ogenstad ogenstad merged commit 89d4e9f into develop Sep 11, 2025
20 checks passed
@ogenstad ogenstad deleted the pog-test-return-types branch September 11, 2025 10:43
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