Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Dec 22, 2025

Split up ignores for test annotations into smaller components and fix some of the violations.

Summary by CodeRabbit

  • Chores
    • Enhanced internal type annotations across test utilities and fixtures for improved code quality and static analysis.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

Walkthrough

This pull request introduces type annotations across multiple test and fixture files. The changes include adding explicit type hints to method parameters in transform classes (TagsTransform, AnimalPerson, ConvertedAnimalPerson) and test functions in the pytest plugin test suite. The conftest.py file receives a type annotation for the pytest hook parameter. Additionally, pyproject.toml is updated to replace a consolidated ANN001 linting suppression rule with granular per-file entries, and an import statement for pytest is added to support the new type annotations.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.33% 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 accurately describes the main changes: addressing test annotation issues and reorganizing linting rules from consolidated to granular entries.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bdc4ca9 and d0dd721.

📒 Files selected for processing (6)
  • pyproject.toml
  • tests/conftest.py
  • tests/fixtures/integration/test_infrahubctl/tags_transform/tags_transform.py
  • tests/fixtures/repos/ctl_integration/transforms/animal_person.py
  • tests/fixtures/repos/ctl_integration/transforms/converted.py
  • tests/unit/pytest_plugin/test_plugin.py
🧰 Additional context used
📓 Path-based instructions (3)
**/*.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:

  • tests/conftest.py
  • tests/fixtures/repos/ctl_integration/transforms/animal_person.py
  • tests/fixtures/repos/ctl_integration/transforms/converted.py
  • tests/fixtures/integration/test_infrahubctl/tags_transform/tags_transform.py
  • tests/unit/pytest_plugin/test_plugin.py
tests/**/*.py

📄 CodeRabbit inference engine (tests/AGENTS.md)

tests/**/*.py: Use httpx_mock fixture for HTTP mocking in tests instead of making real HTTP requests
Do not add @pytest.mark.asyncio decorator to async test functions (async auto-mode is globally enabled)

Files:

  • tests/conftest.py
  • tests/fixtures/repos/ctl_integration/transforms/animal_person.py
  • tests/fixtures/repos/ctl_integration/transforms/converted.py
  • tests/fixtures/integration/test_infrahubctl/tags_transform/tags_transform.py
  • tests/unit/pytest_plugin/test_plugin.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (tests/AGENTS.md)

Unit tests must be fast, mocked, and have no external dependencies

Files:

  • tests/unit/pytest_plugin/test_plugin.py
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-10T17:13:08.136Z
Learning: Applies to **/*.py : Use type hints on all function signatures
📚 Learning: 2025-12-10T17:13:29.593Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: infrahub_sdk/pytest_plugin/AGENTS.md:0-0
Timestamp: 2025-12-10T17:13:29.593Z
Learning: Applies to infrahub_sdk/pytest_plugin/**/infrahub_sdk/pytest_plugin/loader.py : Register new test items in `ITEMS_MAPPING` in `infrahub_sdk/pytest_plugin/loader.py`

Applied to files:

  • tests/conftest.py
  • tests/unit/pytest_plugin/test_plugin.py
📚 Learning: 2025-12-10T17:13:29.593Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: infrahub_sdk/pytest_plugin/AGENTS.md:0-0
Timestamp: 2025-12-10T17:13:29.593Z
Learning: Applies to infrahub_sdk/pytest_plugin/**/infrahub_sdk/pytest_plugin/items/*.py : Inherit from `InfrahubItem` base class when creating new test item classes in `infrahub_sdk/pytest_plugin/items/`

Applied to files:

  • tests/conftest.py
📚 Learning: 2025-12-10T17:13:29.593Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: infrahub_sdk/pytest_plugin/AGENTS.md:0-0
Timestamp: 2025-12-10T17:13:29.593Z
Learning: Applies to infrahub_sdk/pytest_plugin/**/*.yaml : Use YAML test format with required fields: `infrahub_tests`, `resource`, `resource_name`, `tests` array containing `name`, `spec.kind`, `input`, and `output`

Applied to files:

  • tests/unit/pytest_plugin/test_plugin.py
🧬 Code graph analysis (1)
tests/fixtures/repos/ctl_integration/transforms/converted.py (2)
tests/fixtures/repos/ctl_integration/transforms/animal_person.py (1)
  • transform (9-16)
infrahub_sdk/transforms.py (1)
  • transform (53-54)
⏰ 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 (8)
tests/fixtures/repos/ctl_integration/transforms/converted.py (1)

10-10: LGTM! Type annotation added correctly.

The explicit type annotation for the data parameter aligns with the coding guidelines and improves type safety.

tests/fixtures/integration/test_infrahubctl/tags_transform/tags_transform.py (2)

1-2: LGTM! Import added for type annotation support.

The typing.Any import is correctly added to support the type annotation on line 10.


10-10: LGTM! Type annotation added correctly.

The explicit type annotation for the data parameter aligns with the coding guidelines and maintains consistency with other transform methods in this PR.

tests/conftest.py (1)

14-14: LGTM! Pytest hook parameter correctly typed.

The type annotation list[pytest.Item] is correct for the pytest_collection_modifyitems hook and aligns with the coding guidelines requiring type hints on all function signatures.

tests/fixtures/repos/ctl_integration/transforms/animal_person.py (1)

9-9: LGTM! Type annotation added correctly.

The explicit type annotation for the data parameter aligns with the coding guidelines and maintains consistency with the other transform methods updated in this PR.

pyproject.toml (1)

335-379: LGTM! Excellent approach for incremental cleanup.

Breaking down the ANN001 ignores into per-file entries with error counts is a great strategy. This makes it easier to:

  • Track progress on type annotation improvements
  • Target specific files for cleanup
  • Remove entries incrementally as files are fixed

The clear documentation (comments with error counts) provides good visibility into the remaining work.

tests/unit/pytest_plugin/test_plugin.py (2)

1-2: LGTM! Import added for type annotation support.

The pytest import is correctly added to support the pytest.Pytester type annotations used throughout the test functions.


4-4: LGTM! Type annotations added correctly to all test functions.

The pytest.Pytester type annotation is correctly applied to all test function parameters. This aligns with the coding guidelines requiring type hints on all function signatures and improves code clarity.

Also applies to: 10-10, 16-16, 31-31, 69-69, 110-110, 167-167, 239-239


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: d0dd721
Status: ✅  Deploy successful!
Preview URL: https://4e16e02d.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-test-annotations.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@                Coverage Diff                @@
##           infrahub-develop     #707   +/-   ##
=================================================
  Coverage             76.28%   76.28%           
=================================================
  Files                   114      114           
  Lines                  9830     9830           
  Branches               1508     1508           
=================================================
  Hits                   7499     7499           
  Misses                 1837     1837           
  Partials                494      494           
Flag Coverage Δ
integration-tests 34.42% <ø> (ø)
python-3.10 50.17% <ø> (+0.02%) ⬆️
python-3.11 50.17% <ø> (+0.02%) ⬆️
python-3.12 50.15% <ø> (+0.02%) ⬆️
python-3.13 50.13% <ø> (-0.03%) ⬇️
python-3.14 51.80% <ø> (ø)
python-filler-3.12 24.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 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 22, 2025 16:11
@ogenstad ogenstad requested a review from a team December 22, 2025 16:11
@ogenstad ogenstad merged commit 504cda7 into infrahub-develop Dec 23, 2025
21 checks passed
@ogenstad ogenstad deleted the pog-test-annotations branch December 23, 2025 08: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.

3 participants