Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Nov 18, 2025

Remove stuff now that Python 3.9 is phased out.

Summary by CodeRabbit

  • Chores
    • Modernized internal type annotations across the CLI module to use current Python standards, improving code consistency and maintainability without any impact to functionality or existing APIs.

@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Walkthrough

This pull request modernizes type annotations across the CLI module by replacing Optional[T] with PEP 604 union syntax T | None. Changes are applied consistently to nine files in infrahub_sdk/ctl/ directory, including check, cli_commands, generator, graphql, importer, repository, task, utils, and validate modules. The Optional import is removed from each modified file. Additionally, pyproject.toml is updated to remove the UP045 rule from Ruff's ignore list, enabling enforcement of this modern annotation style. No runtime behavior or logic is altered.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.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 clearly and specifically describes the main change: replacing Optional type hints with PEP 604 union syntax and enabling a ruff rule for enforcement.
✨ 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-ruff-up045-20251118-to-infrahub-develop

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21d565e and 26d981c.

📒 Files selected for processing (10)
  • infrahub_sdk/ctl/check.py (2 hunks)
  • infrahub_sdk/ctl/cli_commands.py (6 hunks)
  • infrahub_sdk/ctl/generator.py (2 hunks)
  • infrahub_sdk/ctl/graphql.py (1 hunks)
  • infrahub_sdk/ctl/importer.py (1 hunks)
  • infrahub_sdk/ctl/repository.py (3 hunks)
  • infrahub_sdk/ctl/task.py (1 hunks)
  • infrahub_sdk/ctl/utils.py (2 hunks)
  • infrahub_sdk/ctl/validate.py (1 hunks)
  • pyproject.toml (0 hunks)
💤 Files with no reviewable changes (1)
  • pyproject.toml
🧰 Additional context used
🧬 Code graph analysis (1)
infrahub_sdk/ctl/cli_commands.py (1)
infrahub_sdk/types.py (1)
  • debug (49-50)
🔇 Additional comments (14)
infrahub_sdk/ctl/task.py (1)

76-77: LGTM! Type annotations modernized correctly.

The update from Optional[int] to int | None aligns with PEP 604 union syntax and improves code readability.

infrahub_sdk/ctl/importer.py (1)

29-29: LGTM! Type annotation updated correctly.

The modernization to int | None is consistent with the project-wide type hint improvements.

infrahub_sdk/ctl/utils.py (2)

9-9: LGTM! Import statement cleaned up correctly.

Removing Optional from the imports is appropriate since the code now uses PEP 604 union syntax.


152-152: LGTM! Function signature modernized.

The update to list[str] | None is correct and consistent with modern Python typing practices.

infrahub_sdk/ctl/graphql.py (1)

117-117: LGTM! Type annotation modernized correctly.

The change to Path | None maintains the same semantics while using the modern union syntax.

infrahub_sdk/ctl/check.py (2)

8-8: LGTM! Import statement cleaned up.

Removing Optional is appropriate since the code now uses PEP 604 union syntax throughout.


52-53: LGTM! Function signatures modernized.

Both parameters correctly updated to use str | None syntax, maintaining the same optional behavior.

infrahub_sdk/ctl/validate.py (1)

60-60: LGTM! Type annotation updated correctly.

The modernization to list[str] | None is consistent with the project-wide improvements.

infrahub_sdk/ctl/generator.py (2)

4-4: LGTM! Import statement cleaned up.

Removing Optional is appropriate given the migration to PEP 604 union syntax.


25-25: LGTM! Function signature modernized.

The update to list[str] | None is correct and maintains the same optional parameter behavior.

infrahub_sdk/ctl/repository.py (3)

111-111: LGTM! Type annotation modernized.

The update to str | None for the username parameter is correct and consistent with the project-wide changes.


157-157: LGTM! Type annotation modernized.

The branch parameter correctly uses str | None syntax with typer.Option.


216-221: LGTM! Multiple type annotations modernized correctly.

All three parameters (data, vcs_ref, trust) have been correctly updated to use PEP 604 union syntax (Path | None, str | None, bool | None), maintaining the same optional semantics.

infrahub_sdk/ctl/cli_commands.py (1)

11-11: LGTM! Type annotations modernized consistently.

The migration from Optional[T] to T | None syntax is correctly applied across all function signatures. The project requires Python 3.10+ (per pyproject.toml), which natively supports this syntax, making the changes fully compatible without caveats.


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.

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@                 Coverage Diff                  @@
##           infrahub-develop     #646      +/-   ##
====================================================
- Coverage             75.56%   75.54%   -0.02%     
====================================================
  Files                   113      113              
  Lines                  9514     9509       -5     
  Branches               1448     1448              
====================================================
- Hits                   7189     7184       -5     
  Misses                 1838     1838              
  Partials                487      487              
Flag Coverage Δ
integration-tests 34.93% <100.00%> (-0.04%) ⬇️
python-3.10 48.85% <100.00%> (-0.01%) ⬇️
python-3.11 48.83% <100.00%> (-0.03%) ⬇️
python-3.12 48.83% <100.00%> (-0.03%) ⬇️
python-3.13 48.83% <100.00%> (-0.01%) ⬇️
python-3.9 48.83% <100.00%> (-0.01%) ⬇️
python-filler-3.12 24.30% <0.00%> (+0.01%) ⬆️

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

Files with missing lines Coverage Δ
infrahub_sdk/ctl/check.py 26.44% <100.00%> (ø)
infrahub_sdk/ctl/cli_commands.py 71.08% <100.00%> (ø)
infrahub_sdk/ctl/generator.py 50.90% <100.00%> (ø)
infrahub_sdk/ctl/graphql.py 35.10% <ø> (-0.69%) ⬇️
infrahub_sdk/ctl/importer.py 57.14% <ø> (-1.95%) ⬇️
infrahub_sdk/ctl/repository.py 69.82% <ø> (-0.26%) ⬇️
infrahub_sdk/ctl/task.py 100.00% <ø> (ø)
infrahub_sdk/ctl/utils.py 68.53% <100.00%> (ø)
infrahub_sdk/ctl/validate.py 52.11% <ø> (-0.67%) ⬇️
🚀 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 19, 2025 06:59
@ogenstad ogenstad requested a review from a team November 28, 2025 10:17
@ogenstad ogenstad merged commit 2cf9c3b into infrahub-develop Nov 28, 2025
19 checks passed
@ogenstad ogenstad deleted the pog-ruff-up045-20251118-to-infrahub-develop branch November 28, 2025 12:00
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