Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Dec 19, 2025

Add ty as a type checker, and exclude current violations for each section of the code. Mypy will be removed in a follow up PR.

Summary by CodeRabbit

  • Chores
    • Added an additional static type check to CI to run a new type checker.
    • Introduced project-wide type-checker configuration with targeted rules for source, tests, and docs.
    • Added a task to run the new type checker as part of the lint sequence to strengthen pre-commit/CI validation.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 19, 2025

Walkthrough

The PR integrates the Ty static type checker: adds ty==0.0.4 to lint dependencies in pyproject.toml, introduces a [tool.ty] configuration with Python 3.10 and per-directory overrides for infrahub_sdk, tests, and docs, adds a "Linting: ty check" step to the python-lint job in .github/workflows/ci.yml, and adds a new lint_ty(context: Context) task in tasks.py invoked in lint_all after lint_ruff and before existing mypy and other linters.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add ty as a type checker' directly and clearly summarizes the main objective of the pull request, which is to introduce ty as a new type checking tool.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 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 e19a174 and 8909db5.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • .github/workflows/ci.yml (1 hunks)
  • pyproject.toml (2 hunks)
  • tasks.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml
🧰 Additional context used
📓 Path-based instructions (1)
**/*.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:

  • tasks.py
🧠 Learnings (1)
📚 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: Run `uv run invoke format lint` before committing Python code

Applied to files:

  • tasks.py
🔇 Additional comments (4)
tasks.py (2)

176-183: LGTM! Print statement has been corrected.

The function implementation is correct with proper type hints and context handling. The print statement now accurately reflects that ty is being run, addressing the previous review feedback.


232-232: Appropriate placement in the linting sequence.

Adding lint_ty after lint_ruff and before lint_mypy makes sense as it follows the logical flow of code formatting → type checking → additional type checking with mypy (until it's removed in a future PR).

pyproject.toml (2)

120-180: Extensive ignore rules are appropriately documented as temporary.

The configuration correctly uses comments to indicate that the ignored rules are technical debt to be addressed incrementally. The three-tier approach (infrahub_sdk, tests, docs) with different rule sets for each makes sense for gradual type safety improvement.

Setting python-version = "3.10" aligns with the minimum supported version, ensuring compatibility across all supported Python versions.


85-85: Update the ty version constraint and reassess production readiness.

The pinned version ty==0.0.4 does not exist on PyPI. The latest available version is 0.0.2, released December 16, 2025. Consider updating to the correct version. Additionally, Astral announced a Beta release of ty and stated they are ready to recommend it to motivated users for production use, which addresses earlier concerns about production readiness. However, following the Beta release, Astral is prioritizing support for early adopters, with a Stable release targeted for next year. Verify that this beta-stage dependency is appropriate for your production CI environment.

Likely an incorrect or invalid review comment.


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.

@github-actions github-actions bot added the group/ci Issue related to the CI pipeline label Dec 19, 2025
@cloudflare-workers-and-pages
Copy link

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

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8909db5
Status: ✅  Deploy successful!
Preview URL: https://c80bac5e.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-add-ty-typechecker.infrahub-sdk-python.pages.dev

View logs

@ogenstad ogenstad force-pushed the pog-add-ty-typechecker branch from 71b7c63 to e19a174 Compare December 19, 2025 07:37
@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@           Coverage Diff           @@
##           stable     #702   +/-   ##
=======================================
  Coverage   76.03%   76.03%           
=======================================
  Files         113      113           
  Lines        9743     9743           
  Branches     1490     1490           
=======================================
  Hits         7408     7408           
  Misses       1840     1840           
  Partials      495      495           
Flag Coverage Δ
integration-tests 34.64% <ø> (ø)
python-3.10 49.95% <ø> (-0.03%) ⬇️
python-3.11 49.97% <ø> (ø)
python-3.12 49.93% <ø> (-0.03%) ⬇️
python-3.13 49.93% <ø> (-0.03%) ⬇️
python-3.14 51.59% <ø> (-0.03%) ⬇️
python-filler-3.12 23.94% <ø> (ø)

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 19, 2025 07:55
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

🧹 Nitpick comments (1)
pyproject.toml (1)

125-179: Consider tracking the gradual enablement of ty rules.

The ignored rules are clearly marked as temporary with comments indicating they "should be removed once the code has been updated." This is a reasonable gradual rollout strategy for adopting a new type checker.

To ensure these rules are systematically re-enabled, consider:

  • Creating tracking issues for each category of ignored rules
  • Adding a timeline or milestone for addressing them
  • Periodically reviewing which rules can be enabled as code quality improves
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24d5fba and e19a174.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • .github/workflows/ci.yml (1 hunks)
  • pyproject.toml (2 hunks)
  • tasks.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.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:

  • tasks.py
🧠 Learnings (3)
📚 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: Run `uv run invoke format lint` before committing Python code

Applied to files:

  • tasks.py
  • .github/workflows/ci.yml
📚 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: Run markdownlint before committing markdown changes

Applied to files:

  • .github/workflows/ci.yml
📚 Learning: 2025-12-10T17:13:14.678Z
Learnt from: CR
Repo: opsmill/infrahub-sdk-python PR: 0
File: docs/AGENTS.md:0-0
Timestamp: 2025-12-10T17:13:14.678Z
Learning: Run `uv run invoke docs-validate` after making code changes to verify documentation is current

Applied to files:

  • .github/workflows/ci.yml
⏰ 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 (4)
tasks.py (1)

232-232: LGTM!

Good placement of lint_ty in the lint sequence. Running it before mypy allows both type checkers to provide independent feedback.

pyproject.toml (2)

120-123: Verify the Python version target for ty.

The ty configuration targets Python 3.10, while the project supports Python 3.10-3.14 and the CI runs on Python 3.12. Using the oldest supported version (3.10) for type checking is a reasonable conservative approach, but please confirm this is intentional.


85-85: The pinned version ty==0.0.4 does not exist on PyPI. Verify the correct version and update the dependency—the latest available version is 0.0.2. Also note that ty is still pre-release software; consider whether pinning to a pre-release version is appropriate for your project's stability requirements.

Likely an incorrect or invalid review comment.

.github/workflows/ci.yml (1)

94-95: The python-version = "3.10" setting in [tool.ty.environment] defines the target Python version for type checking analysis, not the Python runtime version. This is intentional and correct—it ensures the code is type-checked against the minimum supported Python version (3.10) rather than the CI environment's Python 3.12. Since ty is a Rust-based tool that runs independently of the Python runtime, no mismatch or inconsistency exists.

Likely an incorrect or invalid review comment.

tasks.py Outdated
@task
def lint_ty(context: Context) -> None:
"""Run ty type checker against all Python files."""
print(" - Check code with mypy")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
print(" - Check code with mypy")
print(" - Check code with ty")

@ogenstad ogenstad force-pushed the pog-add-ty-typechecker branch from e19a174 to 8909db5 Compare December 19, 2025 10:08
@ogenstad ogenstad merged commit eadf3f4 into stable Dec 19, 2025
21 checks passed
@ogenstad ogenstad deleted the pog-add-ty-typechecker branch December 19, 2025 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group/ci Issue related to the CI pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants