Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Dec 30, 2025

Summary by CodeRabbit

  • Tests

    • Added explicit type annotations across many test suites, introduced a small test data class and centralized test cases, and tightened a few test assertions for clearer expectations.
  • Chores

    • Stricter linting rules applied to tests and built-ins, removing several per-file lint exemptions to enforce consistency.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 30, 2025

Walkthrough

pyproject.toml edits remove "input" from the Ruff builtins ignorelist and delete numerous per-file lint-ignore entries for test files. Multiple test modules under tests/unit/sdk/ were modified to add type annotations to function parameters, introduce TYPE_CHECKING blocks for conditional imports, and import new typing symbols. tests/unit/sdk/test_utils.py adds a dataclass ValidURLTestCase and VALID_URL_TEST_CASES and refactors a parametrized test. One test adds an extra assertion checking an initial commit message.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.82% 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 PR title accurately describes the main change: adding type annotations to unit test function signatures across multiple test files.

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

cloudflare-workers-and-pages bot commented Dec 30, 2025

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1506d95
Status: ✅  Deploy successful!
Preview URL: https://2d29725a.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-unit-test-annotations.infrahub-sdk-python.pages.dev

View logs

[pytest.param(tc, id=str(tc.input)) for tc in VALID_URL_TEST_CASES],
)
def test_is_valid_url(input, result) -> None:
assert is_valid_url(input) is result
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored this to get rid of the shadowing of the builtin input() function, and the need to have Any as input in a function signature.

@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@                 Coverage Diff                  @@
##           infrahub-develop     #720      +/-   ##
====================================================
+ Coverage             76.28%   76.29%   +0.01%     
====================================================
  Files                   114      114              
  Lines                  9831     9831              
  Branches               1509     1509              
====================================================
+ Hits                   7500     7501       +1     
+ Misses                 1837     1834       -3     
- Partials                494      496       +2     
Flag Coverage Δ
integration-tests 34.46% <ø> (+0.03%) ⬆️
python-3.10 50.15% <ø> (+0.02%) ⬆️
python-3.11 50.15% <ø> (+0.02%) ⬆️
python-3.12 50.13% <ø> (ø)
python-3.13 50.13% <ø> (ø)
python-3.14 51.79% <ø> (ø)
python-filler-3.12 24.01% <ø> (ø)

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

🚀 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 08:53
@ogenstad ogenstad requested a review from a team December 30, 2025 08:53
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 (2)
tests/unit/sdk/test_utils.py (1)

52-68: Consider renaming the dataclass field and using a more specific type.

The input field name and Any type annotation may conflict with the previous refactoring goal mentioned in the past review comment (line 65), which aimed to eliminate shadowing of the builtin input() function and avoid Any in signatures. While this is now a dataclass field rather than a function parameter, consider:

  • Renaming input to something like url_input or test_input to avoid any shadowing concerns
  • Using str | int instead of Any since all test cases use either str or int values
🔎 Proposed refinement
 @dataclass
 class ValidURLTestCase:
-    input: Any
+    url_input: str | int
     result: bool
 

 VALID_URL_TEST_CASES = [
-    ValidURLTestCase(input=55, result=False),
-    ValidURLTestCase(input="https://", result=False),
+    ValidURLTestCase(url_input=55, result=False),
+    ValidURLTestCase(url_input="https://", result=False),
     # ... update remaining test cases
 ]

 @pytest.mark.parametrize(
     "test_case",
-    [pytest.param(tc, id=str(tc.input)) for tc in VALID_URL_TEST_CASES],
+    [pytest.param(tc, id=str(tc.url_input)) for tc in VALID_URL_TEST_CASES],
 )
 def test_is_valid_url(test_case: ValidURLTestCase) -> None:
-    assert is_valid_url(test_case.input) is test_case.result
+    assert is_valid_url(test_case.url_input) is test_case.result
tests/unit/sdk/test_repository.py (1)

68-68: Minor test enhancement beyond annotation fixes.

While the PR focuses on fixing test annotations, this line adds a new assertion validating the commit message. This is a minor but reasonable test improvement that strengthens the test coverage for repository initialization.

📜 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 36cf741.

📒 Files selected for processing (13)
  • pyproject.toml
  • tests/unit/sdk/checks/test_checks.py
  • tests/unit/sdk/graphql/test_renderer.py
  • tests/unit/sdk/test_batch.py
  • tests/unit/sdk/test_branch.py
  • tests/unit/sdk/test_group_context.py
  • tests/unit/sdk/test_protocols_generator.py
  • tests/unit/sdk/test_query_analyzer.py
  • tests/unit/sdk/test_repository.py
  • tests/unit/sdk/test_schema_sorter.py
  • tests/unit/sdk/test_store_branch.py
  • tests/unit/sdk/test_timestamp.py
  • tests/unit/sdk/test_utils.py
💤 Files with no reviewable changes (1)
  • pyproject.toml
🧰 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/unit/sdk/test_timestamp.py
  • tests/unit/sdk/test_repository.py
  • tests/unit/sdk/test_schema_sorter.py
  • tests/unit/sdk/test_group_context.py
  • tests/unit/sdk/checks/test_checks.py
  • tests/unit/sdk/test_store_branch.py
  • tests/unit/sdk/test_batch.py
  • tests/unit/sdk/test_protocols_generator.py
  • tests/unit/sdk/test_branch.py
  • tests/unit/sdk/test_utils.py
  • tests/unit/sdk/test_query_analyzer.py
  • tests/unit/sdk/graphql/test_renderer.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/unit/sdk/test_timestamp.py
  • tests/unit/sdk/test_repository.py
  • tests/unit/sdk/test_schema_sorter.py
  • tests/unit/sdk/test_group_context.py
  • tests/unit/sdk/checks/test_checks.py
  • tests/unit/sdk/test_store_branch.py
  • tests/unit/sdk/test_batch.py
  • tests/unit/sdk/test_protocols_generator.py
  • tests/unit/sdk/test_branch.py
  • tests/unit/sdk/test_utils.py
  • tests/unit/sdk/test_query_analyzer.py
  • tests/unit/sdk/graphql/test_renderer.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (tests/AGENTS.md)

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

Files:

  • tests/unit/sdk/test_timestamp.py
  • tests/unit/sdk/test_repository.py
  • tests/unit/sdk/test_schema_sorter.py
  • tests/unit/sdk/test_group_context.py
  • tests/unit/sdk/checks/test_checks.py
  • tests/unit/sdk/test_store_branch.py
  • tests/unit/sdk/test_batch.py
  • tests/unit/sdk/test_protocols_generator.py
  • tests/unit/sdk/test_branch.py
  • tests/unit/sdk/test_utils.py
  • tests/unit/sdk/test_query_analyzer.py
  • tests/unit/sdk/graphql/test_renderer.py
🧠 Learnings (4)
📚 Learning: 2025-12-10T17:13:37.990Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: tests/AGENTS.md:0-0
Timestamp: 2025-12-10T17:13:37.990Z
Learning: Applies to tests/**/*.py : Use `httpx_mock` fixture for HTTP mocking in tests instead of making real HTTP requests

Applied to files:

  • tests/unit/sdk/test_schema_sorter.py
  • tests/unit/sdk/checks/test_checks.py
  • tests/unit/sdk/test_protocols_generator.py
📚 Learning: 2025-12-10T17:13:08.136Z
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 infrahub_sdk/client.py : Always provide both async and sync versions of client implementations in InfrahubClient

Applied to files:

  • tests/unit/sdk/checks/test_checks.py
  • tests/unit/sdk/test_branch.py
📚 Learning: 2025-12-10T17:13:08.136Z
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 infrahub_sdk/**/*.py : Follow async/sync dual pattern for new features in the Python SDK

Applied to files:

  • tests/unit/sdk/test_branch.py
📚 Learning: 2025-12-10T17:13:08.136Z
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

Applied to files:

  • tests/unit/sdk/graphql/test_renderer.py
🧬 Code graph analysis (11)
tests/unit/sdk/test_repository.py (1)
infrahub_sdk/repository.py (2)
  • GitRepoManager (9-32)
  • active_branch (31-32)
tests/unit/sdk/test_schema_sorter.py (2)
infrahub_sdk/transfer/schema_sorter.py (1)
  • InfrahubSchemaTopologicalSorter (13-33)
tests/unit/sdk/conftest.py (1)
  • mock_schema_query_01 (1815-1822)
tests/unit/sdk/test_group_context.py (2)
infrahub_sdk/schema/main.py (1)
  • NodeSchemaAPI (312-314)
tests/unit/sdk/conftest.py (3)
  • replace_sync_return_annotation (121-128)
  • replace_async_return_annotation (95-101)
  • std_group_schema (291-301)
tests/unit/sdk/checks/test_checks.py (2)
tests/unit/sdk/conftest.py (1)
  • client (32-33)
tests/unit/sdk/checks/conftest.py (1)
  • mock_gql_query_my_query (13-22)
tests/unit/sdk/test_store_branch.py (3)
infrahub_sdk/schema/main.py (1)
  • NodeSchemaAPI (312-314)
infrahub_sdk/store.py (1)
  • NodeStoreBranch (25-189)
tests/unit/sdk/conftest.py (1)
  • schema_with_hfid (226-287)
tests/unit/sdk/test_batch.py (1)
tests/unit/sdk/conftest.py (2)
  • mock_query_mutation_location_create_failed (2152-2169)
  • mock_schema_query_01 (1815-1822)
tests/unit/sdk/test_protocols_generator.py (1)
tests/unit/sdk/conftest.py (2)
  • client (32-33)
  • mock_schema_query_05 (1843-1850)
tests/unit/sdk/test_branch.py (1)
tests/unit/sdk/conftest.py (3)
  • BothClients (25-28)
  • clients (42-46)
  • mock_branches_list_query (1429-1465)
tests/unit/sdk/test_utils.py (2)
infrahub_sdk/utils.py (1)
  • is_valid_url (215-227)
tests/unit/sdk/conftest.py (2)
  • query_01 (2186-2209)
  • query_02 (2213-2254)
tests/unit/sdk/test_query_analyzer.py (1)
tests/unit/sdk/conftest.py (2)
  • query_01 (2186-2209)
  • bad_query_01 (2375-2395)
tests/unit/sdk/graphql/test_renderer.py (1)
tests/unit/sdk/graphql/conftest.py (4)
  • query_data_no_filter (18-25)
  • query_data_alias (29-36)
  • query_data_fragment (40-49)
  • input_data_01 (94-103)
⏰ 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 (17)
tests/unit/sdk/test_timestamp.py (1)

66-66: LGTM! Type annotations correctly added to parametrized test functions.

The type hints for input_str, expected_datetime, expected_str, expected_str_no_z, and invalid_str are accurate and align with the test parameter values.

Also applies to: 88-88, 132-132

tests/unit/sdk/test_protocols_generator.py (2)

2-2: LGTM! Proper use of TYPE_CHECKING guard.

The TYPE_CHECKING import guard correctly avoids runtime imports while providing type hints for static analysis.

Also applies to: 9-11


48-48: LGTM! Correct forward reference type annotation.

The "HTTPXMock" forward reference string is the correct approach when the type is only imported under TYPE_CHECKING.

tests/unit/sdk/test_utils.py (1)

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

The query_01: str and query_02: str annotations are accurate and match the fixture return types.

Also applies to: 185-185

tests/unit/sdk/graphql/test_renderer.py (2)

1-2: LGTM! Proper import addition.

The Any import is necessary for the dict[str, Any] type annotations added to test functions.


6-6: LGTM! Type annotations correctly added.

The dict[str, Any] annotations for query_data_no_filter, query_data_alias, query_data_fragment, and input_data_01 are accurate and match the fixture return types.

Also applies to: 49-49, 71-71, 95-95

tests/unit/sdk/checks/test_checks.py (2)

2-2: LGTM! Proper TYPE_CHECKING guard usage.

The TYPE_CHECKING pattern correctly avoids runtime imports while enabling static type checking.

Also applies to: 9-11


43-43: LGTM! Type annotations correctly added.

The annotations for client: InfrahubClient and mock_gql_query_my_query: "HTTPXMock" are accurate. The forward reference string is the correct approach for TYPE_CHECKING imports.

Also applies to: 51-51

tests/unit/sdk/test_branch.py (3)

1-2: LGTM! Proper use of postponed annotations.

The from __future__ import annotations enables PEP 563 postponed evaluation, allowing cleaner type hints without forward reference strings.


4-4: LGTM! Proper TYPE_CHECKING guard usage.

The TYPE_CHECKING pattern correctly imports HTTPXMock and BothClients for type checking without runtime overhead.

Also applies to: 14-18


32-32: LGTM! Type annotations correctly added.

The annotations for method: str, clients: BothClients, mock_branches_list_query: HTTPXMock, and client_type: str are accurate and leverage the postponed annotations from __future__ import.

Also applies to: 42-42

tests/unit/sdk/test_batch.py (1)

51-57: LGTM! Type annotations correctly added.

The HTTPXMock annotations for mock_query_mutation_location_create_failed and mock_schema_query_01 in both test_batch_return_exception and test_batch_exception are accurate and consistent with the existing TYPE_CHECKING pattern in this file.

Also applies to: 97-103

tests/unit/sdk/test_query_analyzer.py (1)

8-8: LGTM! Type annotations correctly added.

The type hints for query_01: str, bad_query_01: str, var_type: str, and var_required: bool are accurate and align with the corresponding fixture return types and parametrize values.

Also applies to: 154-154

tests/unit/sdk/test_repository.py (1)

20-20: LGTM! Type annotations improve test type safety.

The explicit type annotations on all test function parameters are correct and align with the coding guidelines requiring type hints on all function signatures.

Also applies to: 32-32, 43-43, 51-51, 63-63

tests/unit/sdk/test_group_context.py (1)

2-2: LGTM! Type annotations are correctly applied.

The type annotations accurately reflect the fixture definitions:

  • Callable[[str], str] matches the return type of the replacement annotation fixtures
  • NodeSchemaAPI matches the std_group_schema fixture type

The necessary imports are correctly added, and the annotations improve type safety without affecting test behavior.

Also applies to: 7-7, 23-25, 72-72

tests/unit/sdk/test_store_branch.py (1)

6-6: LGTM! Type annotations correctly match fixture definitions.

The NodeSchemaAPI type annotations accurately reflect the fixture return types:

  • schema_with_hfid fixture returns dict[str, NodeSchemaAPI]
  • location_schema fixture returns NodeSchemaAPI

These annotations improve type checking without any functional changes.

Also applies to: 10-10, 26-26, 43-43, 69-69

tests/unit/sdk/test_schema_sorter.py (1)

1-1: LGTM! Proper use of TYPE_CHECKING pattern.

The TYPE_CHECKING guard correctly avoids runtime imports while enabling static type checking:

  • HTTPXMock is imported only during type checking
  • Forward reference "HTTPXMock" is properly used in the function signature
  • The annotation matches the mock_schema_query_01 fixture return type

This pattern reduces runtime overhead while improving type safety.

Also applies to: 6-8, 10-10



async def test_validate_sync_async(mock_gql_query_my_query) -> None:
async def test_validate_sync_async(mock_gql_query_my_query: "HTTPXMock") -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to quote the type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. It was just missing the from __future__ import annotations statement. I've removed the quotes.

@ogenstad ogenstad force-pushed the pog-unit-test-annotations branch from 36cf741 to 1506d95 Compare December 30, 2025 10:24
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/checks/test_checks.py (1)

1-13: Consider removing unnecessary quotes for consistency.

With from __future__ import annotations, all type annotations are automatically converted to strings at runtime, so the explicit quotes around "HTTPXMock" on Line 53 are unnecessary. Other files in this PR (test_branch.py, test_batch.py) use from __future__ import annotations without quoting types under TYPE_CHECKING.

For consistency, you could remove the quotes on Line 53.

🔎 Proposed consistency fix

On Line 53:

-async def test_validate_sync_async(mock_gql_query_my_query: "HTTPXMock") -> None:
+async def test_validate_sync_async(mock_gql_query_my_query: HTTPXMock) -> None:
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36cf741 and 1506d95.

📒 Files selected for processing (13)
  • pyproject.toml
  • tests/unit/sdk/checks/test_checks.py
  • tests/unit/sdk/graphql/test_renderer.py
  • tests/unit/sdk/test_batch.py
  • tests/unit/sdk/test_branch.py
  • tests/unit/sdk/test_group_context.py
  • tests/unit/sdk/test_protocols_generator.py
  • tests/unit/sdk/test_query_analyzer.py
  • tests/unit/sdk/test_repository.py
  • tests/unit/sdk/test_schema_sorter.py
  • tests/unit/sdk/test_store_branch.py
  • tests/unit/sdk/test_timestamp.py
  • tests/unit/sdk/test_utils.py
💤 Files with no reviewable changes (1)
  • pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/unit/sdk/test_query_analyzer.py
  • tests/unit/sdk/test_timestamp.py
  • tests/unit/sdk/test_group_context.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/unit/sdk/test_protocols_generator.py
  • tests/unit/sdk/test_batch.py
  • tests/unit/sdk/test_store_branch.py
  • tests/unit/sdk/test_schema_sorter.py
  • tests/unit/sdk/test_branch.py
  • tests/unit/sdk/graphql/test_renderer.py
  • tests/unit/sdk/test_utils.py
  • tests/unit/sdk/checks/test_checks.py
  • tests/unit/sdk/test_repository.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/unit/sdk/test_protocols_generator.py
  • tests/unit/sdk/test_batch.py
  • tests/unit/sdk/test_store_branch.py
  • tests/unit/sdk/test_schema_sorter.py
  • tests/unit/sdk/test_branch.py
  • tests/unit/sdk/graphql/test_renderer.py
  • tests/unit/sdk/test_utils.py
  • tests/unit/sdk/checks/test_checks.py
  • tests/unit/sdk/test_repository.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (tests/AGENTS.md)

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

Files:

  • tests/unit/sdk/test_protocols_generator.py
  • tests/unit/sdk/test_batch.py
  • tests/unit/sdk/test_store_branch.py
  • tests/unit/sdk/test_schema_sorter.py
  • tests/unit/sdk/test_branch.py
  • tests/unit/sdk/graphql/test_renderer.py
  • tests/unit/sdk/test_utils.py
  • tests/unit/sdk/checks/test_checks.py
  • tests/unit/sdk/test_repository.py
🧠 Learnings (7)
📚 Learning: 2025-12-10T17:13:37.990Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: tests/AGENTS.md:0-0
Timestamp: 2025-12-10T17:13:37.990Z
Learning: Applies to tests/**/*.py : Use `httpx_mock` fixture for HTTP mocking in tests instead of making real HTTP requests

Applied to files:

  • tests/unit/sdk/test_protocols_generator.py
  • tests/unit/sdk/test_schema_sorter.py
  • tests/unit/sdk/checks/test_checks.py
📚 Learning: 2025-12-10T17:13:08.136Z
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 infrahub_sdk/client.py : Always provide both async and sync versions of client implementations in InfrahubClient

Applied to files:

  • tests/unit/sdk/test_branch.py
  • tests/unit/sdk/checks/test_checks.py
📚 Learning: 2025-12-10T17:13:08.136Z
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 infrahub_sdk/**/*.py : Follow async/sync dual pattern for new features in the Python SDK

Applied to files:

  • tests/unit/sdk/test_branch.py
📚 Learning: 2025-12-10T17:13:08.136Z
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

Applied to files:

  • tests/unit/sdk/checks/test_checks.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/unit/sdk/checks/test_checks.py
📚 Learning: 2025-12-10T17:13:37.990Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: tests/AGENTS.md:0-0
Timestamp: 2025-12-10T17:13:37.990Z
Learning: Applies to tests/integration/**/*.py : Integration tests should use testcontainers to interact with real Infrahub instances

Applied to files:

  • tests/unit/sdk/checks/test_checks.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/sdk/checks/test_checks.py
🧬 Code graph analysis (8)
tests/unit/sdk/test_protocols_generator.py (1)
tests/unit/sdk/conftest.py (2)
  • client (32-33)
  • mock_schema_query_05 (1843-1850)
tests/unit/sdk/test_batch.py (1)
tests/unit/sdk/conftest.py (2)
  • mock_query_mutation_location_create_failed (2152-2169)
  • mock_schema_query_01 (1815-1822)
tests/unit/sdk/test_store_branch.py (3)
infrahub_sdk/schema/main.py (1)
  • NodeSchemaAPI (312-314)
infrahub_sdk/store.py (1)
  • NodeStoreBranch (25-189)
tests/unit/sdk/conftest.py (2)
  • schema_with_hfid (226-287)
  • location_schema (148-180)
tests/unit/sdk/test_schema_sorter.py (2)
infrahub_sdk/transfer/schema_sorter.py (1)
  • InfrahubSchemaTopologicalSorter (13-33)
tests/unit/sdk/conftest.py (1)
  • mock_schema_query_01 (1815-1822)
tests/unit/sdk/test_branch.py (1)
tests/unit/sdk/conftest.py (3)
  • BothClients (25-28)
  • clients (42-46)
  • mock_branches_list_query (1429-1465)
tests/unit/sdk/graphql/test_renderer.py (2)
infrahub_sdk/graphql/renderers.py (2)
  • render_input_block (156-216)
  • render_query_block (87-153)
tests/unit/sdk/graphql/conftest.py (4)
  • query_data_no_filter (18-25)
  • query_data_alias (29-36)
  • query_data_fragment (40-49)
  • input_data_01 (94-103)
tests/unit/sdk/test_utils.py (2)
infrahub_sdk/utils.py (1)
  • is_valid_url (215-227)
tests/unit/sdk/conftest.py (2)
  • query_01 (2186-2209)
  • query_02 (2213-2254)
tests/unit/sdk/checks/test_checks.py (2)
tests/unit/sdk/conftest.py (1)
  • client (32-33)
tests/unit/sdk/checks/conftest.py (1)
  • mock_gql_query_my_query (13-22)
⏰ 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). (7)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: unit-tests (3.14)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: integration-tests-latest-infrahub
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (13)
tests/unit/sdk/graphql/test_renderer.py (5)

1-1: LGTM! Import added correctly.

The Any import is necessary for the dict[str, Any] type hints added throughout the file.


6-6: LGTM! Type annotations added correctly.

The type hint correctly matches the fixture's return type from conftest.py. This aligns with the coding guideline to use type hints on all function signatures.


49-49: LGTM! Type annotations added correctly.

The type hint correctly matches the fixture's return type and maintains consistency with the other test functions in the file.


71-71: LGTM! Type annotations added correctly.

The type hint correctly matches the fixture's return type and maintains consistency with the other test functions in the file.


95-95: LGTM! Type annotations added correctly.

The type hint correctly matches the fixture's return type and maintains consistency with the other test functions in the file.

tests/unit/sdk/test_protocols_generator.py (1)

2-11: LGTM! Correct use of TYPE_CHECKING guard.

The TYPE_CHECKING guard correctly prevents runtime import of HTTPXMock, and the quoted type hint on Line 48 is necessary since from __future__ import annotations is not used.

tests/unit/sdk/test_store_branch.py (1)

6-6: LGTM! Proper type annotations added.

The NodeSchemaAPI import and type hints correctly annotate test parameters, improving type safety without affecting runtime behavior.

tests/unit/sdk/test_branch.py (1)

1-18: LGTM! Proper typing enhancements.

The use of from __future__ import annotations with TYPE_CHECKING guards is correctly implemented, and type hints are consistently applied without unnecessary quotes.

tests/unit/sdk/test_schema_sorter.py (1)

1-10: LGTM! Correct TYPE_CHECKING pattern.

The quoted type hint is necessary since from __future__ import annotations is not used, preventing NameError at runtime while maintaining type checking support.

tests/unit/sdk/test_utils.py (2)

52-76: Excellent refactoring!

The introduction of ValidURLTestCase dataclass and structured test cases improves the test code by:

  • Eliminating shadowing of the builtin input function
  • Providing clear, explicit test case definitions
  • Making test data more maintainable and self-documenting

170-185: LGTM! Type hints added correctly.

The type annotations for the fixture parameters improve type safety and code clarity.

tests/unit/sdk/test_repository.py (1)

20-68: LGTM! Type annotations and test coverage improvements.

The type hints are correctly added to all test functions, and the additional assertion on Line 68 provides valuable verification of the initial commit message.

tests/unit/sdk/test_batch.py (1)

51-100: LGTM! Consistent typing approach.

The HTTPXMock type hints are correctly applied without quotes, consistent with the use of from __future__ import annotations. The changes improve type safety without affecting test behavior.

@ogenstad ogenstad merged commit 854412b into infrahub-develop Dec 30, 2025
21 checks passed
@ogenstad ogenstad deleted the pog-unit-test-annotations branch December 30, 2025 10:53
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