Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Nov 17, 2025

Removes support for Python 3.9, and backported package specifically for 3.9. Due to this there were a number of linting changes that needed to be done as the new target version became 3.10.

Summary by CodeRabbit

  • Breaking Changes

    • Python 3.9 support has been removed; minimum required version is now Python 3.10.
  • Chores

    • Internal code modernization and dependency cleanup.

@coderabbitai
Copy link

coderabbitai bot commented Nov 17, 2025

Walkthrough

This pull request removes Python 3.9 support and modernizes the codebase to leverage Python 3.10+ features. Changes include updating pyproject.toml to require Python 3.10+, removing the eval-type-backport dependency, and migrating type imports across multiple files from typing.Callable to collections.abc.Callable. Union type annotations are replaced with the PEP 604 union operator (|) throughout the codebase. Additionally, zip() calls are updated with explicit strict=False parameters, async iteration syntax is modernized, and Ruff configuration ignores are simplified.

Pre-merge checks and finishing touches

❌ 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 'Remove support for Python 3.9' directly and clearly summarizes the main change in the pull request.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pog-remove-python-3.9

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: 46092e3
Status: ✅  Deploy successful!
Preview URL: https://4d549245.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-remove-python-3-9.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/transfer/importer/json.py 0.00% 1 Missing ⚠️
@@                 Coverage Diff                  @@
##           infrahub-develop     #635      +/-   ##
====================================================
- Coverage             75.56%   75.56%   -0.01%     
====================================================
  Files                   113      113              
  Lines                  9512     9514       +2     
  Branches               1448     1448              
====================================================
+ Hits                   7188     7189       +1     
- Misses                 1837     1838       +1     
  Partials                487      487              
Flag Coverage Δ
integration-tests 34.96% <25.00%> (+0.01%) ⬆️
python-3.10 48.88% <29.16%> (+0.01%) ⬆️
python-3.11 48.88% <29.16%> (+0.03%) ⬆️
python-3.12 48.84% <29.16%> (-0.02%) ⬇️
python-3.13 48.84% <29.16%> (-0.02%) ⬇️
python-3.9 48.86% <29.16%> (+1.30%) ⬆️
python-filler-3.12 24.29% <66.66%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
infrahub_sdk/async_typer.py 100.00% <100.00%> (ø)
infrahub_sdk/batch.py 94.52% <100.00%> (ø)
infrahub_sdk/client.py 68.22% <100.00%> (-0.11%) ⬇️
infrahub_sdk/ctl/cli_commands.py 71.08% <100.00%> (+0.11%) ⬆️
infrahub_sdk/ctl/utils.py 68.53% <100.00%> (ø)
infrahub_sdk/node/attribute.py 95.06% <100.00%> (+0.06%) ⬆️
infrahub_sdk/node/constants.py 100.00% <100.00%> (ø)
infrahub_sdk/schema/__init__.py 67.52% <100.00%> (-0.10%) ⬇️
infrahub_sdk/schema/main.py 89.49% <100.00%> (ø)
infrahub_sdk/schema/repository.py 87.41% <100.00%> (ø)
... and 4 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 November 17, 2025 10:52
@ogenstad ogenstad requested a review from a team November 17, 2025 10:52
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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9633d0 and 46092e3.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (17)
  • changelog/+f97cdf92.removed.md (1 hunks)
  • infrahub_sdk/async_typer.py (1 hunks)
  • infrahub_sdk/batch.py (1 hunks)
  • infrahub_sdk/client.py (1 hunks)
  • infrahub_sdk/ctl/cli_commands.py (1 hunks)
  • infrahub_sdk/ctl/utils.py (1 hunks)
  • infrahub_sdk/node/attribute.py (1 hunks)
  • infrahub_sdk/node/constants.py (1 hunks)
  • infrahub_sdk/schema/__init__.py (3 hunks)
  • infrahub_sdk/schema/main.py (1 hunks)
  • infrahub_sdk/schema/repository.py (2 hunks)
  • infrahub_sdk/spec/range_expansion.py (1 hunks)
  • infrahub_sdk/template/__init__.py (1 hunks)
  • infrahub_sdk/transfer/importer/json.py (1 hunks)
  • infrahub_sdk/types.py (2 hunks)
  • pyproject.toml (1 hunks)
  • tests/unit/sdk/test_batch.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
infrahub_sdk/schema/repository.py (1)
infrahub_sdk/node/node.py (2)
  • InfrahubNode (458-1086)
  • InfrahubNodeSync (1089-1712)
infrahub_sdk/schema/main.py (1)
infrahub_sdk/node/node.py (2)
  • InfrahubNode (458-1086)
  • InfrahubNodeSync (1089-1712)
infrahub_sdk/schema/__init__.py (2)
infrahub_sdk/node/node.py (2)
  • InfrahubNode (458-1086)
  • InfrahubNodeSync (1089-1712)
infrahub_sdk/schema/main.py (6)
  • NodeSchema (307-309)
  • GenericSchema (283-285)
  • NodeSchemaAPI (312-314)
  • GenericSchemaAPI (288-292)
  • ProfileSchemaAPI (317-318)
  • TemplateSchemaAPI (321-322)
⏰ 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 (16)
changelog/+f97cdf92.removed.md (1)

1-1: LGTM! Clear documentation of Python 3.9 removal.

The changelog entry accurately documents the removal of Python 3.9 support.

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

70-70: LGTM! Proper use of anext() for Python 3.10+.

The migration from result_iter.__anext__() to await anext(result_iter) is the idiomatic way to iterate async iterators in Python 3.10+.

Also applies to: 75-75

infrahub_sdk/template/__init__.py (1)

4-6: LGTM! Proper import modernization for Python 3.10+.

Moving Callable from typing to collections.abc aligns with Python 3.10+ best practices. The type annotations remain functionally identical.

infrahub_sdk/batch.py (1)

4-7: LGTM! Comprehensive import modernization for Python 3.10+.

Moving Callable, AsyncGenerator, Awaitable, and Generator from typing to collections.abc is the correct approach for Python 3.10+. All type annotations remain functionally identical.

infrahub_sdk/node/attribute.py (1)

4-5: LGTM! Proper import modernization for Python 3.10+.

Moving Callable from typing to collections.abc aligns with Python 3.10+ best practices. The type annotations remain functionally identical.

infrahub_sdk/spec/range_expansion.py (1)

70-72: LGTM! Explicit strict=False improves clarity.

Adding strict=False to the zip() call makes the behavior explicit. While this is the default in Python 3.10+, explicitly stating it improves code clarity.

infrahub_sdk/client.py (1)

8-19: LGTM! Comprehensive import modernization for Python 3.10+.

Moving Callable, Coroutine, Mapping, and MutableMapping from typing to collections.abc is the correct approach for Python 3.10+. All type annotations remain functionally identical.

infrahub_sdk/async_typer.py (1)

5-7: LGTM! Proper import modernization for Python 3.10+.

Moving Callable from typing to collections.abc aligns with Python 3.10+ best practices. The type annotations remain functionally identical.

pyproject.toml (1)

10-10: LGTM! Python version requirement updated correctly.

The change to require Python 3.10+ aligns with the PR objective to drop Python 3.9 support and enables the use of modern typing syntax throughout the codebase.

infrahub_sdk/types.py (1)

5-5: LGTM! Type alias modernized to Python 3.10+ syntax.

The migration from Union[InfrahubLogger, Logger] to InfrahubLogger | Logger using PEP 604 union syntax is correct and consistent with the Python 3.10+ requirement.

Also applies to: 68-68

infrahub_sdk/node/constants.py (1)

8-8: LGTM! Type alias updated to modern union syntax.

The change from Union[...] to the | operator for IP_TYPES is consistent with Python 3.10+ requirements and maintains the same type semantics.

infrahub_sdk/ctl/utils.py (1)

6-6: LGTM! Callable import moved to recommended location.

Migrating Callable from typing to collections.abc aligns with Python 3.9+ best practices, where typing.Callable is deprecated in favor of collections.abc.Callable.

Also applies to: 9-9

infrahub_sdk/schema/repository.py (1)

4-4: LGTM! Type alias modernized within TYPE_CHECKING block.

The update to use PEP 604 union syntax (InfrahubNode | InfrahubNodeSync) instead of Union is correct and consistent with the Python 3.10+ migration.

Also applies to: 21-21

infrahub_sdk/ctl/cli_commands.py (1)

9-9: LGTM! Callable import standardized.

The migration of Callable from typing to collections.abc follows Python best practices and is consistent with similar changes throughout the codebase.

Also applies to: 11-11

infrahub_sdk/schema/__init__.py (1)

10-10: LGTM! Type aliases modernized with explicit TypeAlias annotation.

The introduction of explicit TypeAlias annotations combined with PEP 604 union syntax makes the type aliases clearer and follows Python 3.10+ best practices. The changes are consistent across all type alias definitions in the file.

Also applies to: 48-48, 86-90

infrahub_sdk/schema/main.py (1)

6-6: LGTM! Type annotation updated to modern union syntax.

The migration from Union[InfrahubNode, InfrahubNodeSync] to InfrahubNode | InfrahubNodeSync within the TYPE_CHECKING block is consistent with the Python 3.10+ modernization across the codebase.

Also applies to: 14-14

with self.wrapped_task_output("Analyzing import"):
import_nodes_by_kind = defaultdict(list)
for graphql_data, kind in zip(table.column("graphql_json"), table.column("kind")):
for graphql_data, kind in zip(table.column("graphql_json"), table.column("kind"), strict=False):
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Consider using strict=True for data integrity.

Since both columns come from the same table, they should always have identical lengths. Using strict=False would silently skip rows if the columns have mismatched lengths due to data corruption or a bug, potentially causing incomplete imports.

Apply this diff to fail fast on data integrity issues:

-            for graphql_data, kind in zip(table.column("graphql_json"), table.column("kind"), strict=False):
+            for graphql_data, kind in zip(table.column("graphql_json"), table.column("kind"), strict=True):
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for graphql_data, kind in zip(table.column("graphql_json"), table.column("kind"), strict=False):
for graphql_data, kind in zip(table.column("graphql_json"), table.column("kind"), strict=True):
🤖 Prompt for AI Agents
In infrahub_sdk/transfer/importer/json.py around line 65, the zip over
table.column("graphql_json") and table.column("kind") uses strict=False which
can silently drop mismatched rows; change it to strict=True to raise an error on
length mismatches so the importer fails fast on data integrity issues, and
handle or propagate the resulting exception where appropriate (e.g., let it
bubble up or catch and log a clear error message).

@ogenstad ogenstad merged commit 5819312 into infrahub-develop Nov 17, 2025
20 checks passed
@ogenstad ogenstad deleted the pog-remove-python-3.9 branch November 17, 2025 15:30
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