Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Nov 17, 2025

Upgrade ruff, and add some autofixable errors due to violations in the new version. Also added a new rule to the list of exceptions (Async functions should not use pathlib.Path methods, use trio.Path or anyio.path, this one would be good to fix in an upcoming PR though).

Summary by CodeRabbit

  • Chores
    • Updated development linting tool to the latest version
    • Ensured consistent UTF-8 encoding across file operations and configurations

@coderabbitai
Copy link

coderabbitai bot commented Nov 17, 2025

Walkthrough

This pull request updates the ruff linter from version 0.11.0 to 0.14.5 across workflow configuration, documentation, and dependencies. Multiple file operations are updated to explicitly specify UTF-8 encoding when reading and writing text files. Default arguments are simplified in several dictionary.get() calls by removing explicit None defaults. The linting configuration is augmented to include ASYNC240 in the per-file-ignores ruleset.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% 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 reflects the main change: upgrading ruff from 0.11.0 to 0.14.5 across multiple configuration files and addressing compatibility issues.
✨ 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-upgrade-ruff

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 Nov 17, 2025

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2470982
Status: ✅  Deploy successful!
Preview URL: https://dee4d948.infrahub-sdk-python.pages.dev
Branch Preview URL: https://pog-upgrade-ruff.infrahub-sdk-python.pages.dev

View logs

@github-actions github-actions bot added the group/ci Issue related to the CI pipeline label Nov 17, 2025
@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/ctl/graphql.py 0.00% 1 Missing ⚠️
...frahub_sdk/pytest_plugin/items/jinja2_transform.py 0.00% 1 Missing ⚠️
infrahub_sdk/transfer/importer/json.py 0.00% 1 Missing ⚠️
@@                Coverage Diff                @@
##           infrahub-develop     #636   +/-   ##
=================================================
  Coverage             75.56%   75.56%           
=================================================
  Files                   113      113           
  Lines                  9514     9514           
  Branches               1448     1448           
=================================================
  Hits                   7189     7189           
  Misses                 1838     1838           
  Partials                487      487           
Flag Coverage Δ
integration-tests 34.96% <69.23%> (ø)
python-3.10 48.86% <76.92%> (-0.03%) ⬇️
python-3.11 48.88% <76.92%> (ø)
python-3.12 48.84% <76.92%> (ø)
python-3.13 48.86% <76.92%> (+0.02%) ⬆️
python-3.9 48.84% <76.92%> (-0.03%) ⬇️
python-filler-3.12 24.29% <0.00%> (ø)

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

Files with missing lines Coverage Δ
infrahub_sdk/node/attribute.py 95.06% <100.00%> (ø)
infrahub_sdk/node/related_node.py 90.25% <100.00%> (ø)
infrahub_sdk/utils.py 86.30% <100.00%> (ø)
infrahub_sdk/ctl/graphql.py 35.78% <0.00%> (ø)
...frahub_sdk/pytest_plugin/items/jinja2_transform.py 60.29% <0.00%> (ø)
infrahub_sdk/transfer/importer/json.py 15.38% <0.00%> (ø)
🚀 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 16:46
@ogenstad ogenstad requested a review from a team November 17, 2025 16:46
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)
pyproject.toml (1)

249-251: ASYNC240 added to ignores—tracked for future fix.

Adding ASYNC240 (async pathlib.Path usage) to per-file-ignores is reasonable for now, as noted in the PR description. This rule flags async functions using pathlib.Path methods instead of async-friendly alternatives like anyio.path.

Would you like me to search the codebase for async functions using pathlib.Path methods to assess the scope of work needed for the future PR that addresses this rule?

#!/bin/bash
# Find async functions that may be using pathlib.Path methods
ast-grep --pattern $'async def $FUNC($$$) {
  $$$
  $_.read_text($$$)
  $$$
}'

ast-grep --pattern $'async def $FUNC($$$) {
  $$$
  $_.write_text($$$)
  $$$
}'
infrahub_sdk/node/related_node.py (1)

74-74: Consider applying the same cleanup for consistency.

Line 74 has the same nested .get() pattern with an explicit None default that could be removed for consistency with the change on line 67.

Apply this diff to remove the redundant None:

-                prop_data = properties_data.get(prop, properties_data.get(f"_relation__{prop}", None))
+                prop_data = properties_data.get(prop, properties_data.get(f"_relation__{prop}"))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5819312 and 2470982.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • .github/workflows/ci.yml (1 hunks)
  • CLAUDE.md (1 hunks)
  • infrahub_sdk/ctl/graphql.py (1 hunks)
  • infrahub_sdk/node/attribute.py (2 hunks)
  • infrahub_sdk/node/related_node.py (1 hunks)
  • infrahub_sdk/pytest_plugin/items/jinja2_transform.py (1 hunks)
  • infrahub_sdk/transfer/importer/json.py (1 hunks)
  • infrahub_sdk/utils.py (1 hunks)
  • pyproject.toml (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
infrahub_sdk/utils.py (1)
infrahub_sdk/testing/repository.py (1)
  • path (57-58)
⏰ 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 (9)
infrahub_sdk/ctl/graphql.py (1)

111-111: LGTM! Explicit UTF-8 encoding is best practice.

Adding explicit encoding="utf-8" to write_text() ensures consistent behavior across platforms and aligns with PEP 597 recommendations.

infrahub_sdk/pytest_plugin/items/jinja2_transform.py (1)

86-86: LGTM! Explicit UTF-8 encoding for template files.

Adding encoding="utf-8" to read_text() ensures consistent decoding of Jinja2 templates across platforms.

infrahub_sdk/transfer/importer/json.py (1)

147-147: LGTM! Explicit UTF-8 encoding for JSON files.

Adding encoding="utf-8" to read_text() ensures consistent decoding of JSON relationship data.

pyproject.toml (1)

84-84: Ruff version upgrade is consistent.

The upgrade to 0.14.5 matches the CI workflow update and enables the new lint rules that prompted the encoding fixes in this PR.

CLAUDE.md (1)

167-167: Documentation updated to reflect ruff 0.14.5.

Keeping the documentation in sync with the actual version upgrade is good practice.

infrahub_sdk/utils.py (1)

321-321: LGTM! Explicit UTF-8 encoding for file writes.

Adding encoding="utf-8" to write_text() ensures consistent behavior across platforms and completes the UTF-8 encoding consistency improvements in this PR.

infrahub_sdk/node/attribute.py (1)

38-57: LGTM! Simplified dict.get() calls are functionally equivalent.

Removing explicit None defaults from data.get() calls is functionally equivalent since dict.get() returns None by default when the key is not found. This appears to be an autofixable ruff simplification that improves code clarity without changing behavior.

.github/workflows/ci.yml (1)

81-81: Verify Ruff upgrade impact on configuration and linting behavior.

The upgrade from 0.11.0 to 0.14.5 includes notable changes that require verification:

  • Default Python target updated to 3.14 in 0.14.x series, which can affect rule applicability and diagnostics
  • New/stabilized rules and preview features promoted across 0.12–0.14, which can change which diagnostics are reported by default
  • Ruff uses minor-version bumps for potentially breaking changes in config and stable-rule behavior

Before merging, confirm:

  1. Your project's requires-python and target-version settings are correct for Python 3.14 (or explicitly pin if needed)
  2. Run linting with 0.14.5 and verify the rule output hasn't unexpectedly changed or broken any existing lint configurations
  3. Review the Ruff CHANGELOG for any rules relevant to your codebase
infrahub_sdk/node/related_node.py (1)

67-67: LGTM! Redundant None default removed.

The explicit None default in the inner .get() call is unnecessary since .get() returns None by default when the key is not found. This cleanup aligns with the ruff upgrade objectives.

@ogenstad ogenstad merged commit 6060485 into infrahub-develop Nov 17, 2025
20 checks passed
@ogenstad ogenstad deleted the pog-upgrade-ruff branch November 17, 2025 18:22
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