Skip to content

fix: correct import sorting and pin tool versions to fix CI lint#153

Open
Ckk3 wants to merge 6 commits intogazorby:mainfrom
Ckk3:fix/lint-import-sorting
Open

fix: correct import sorting and pin tool versions to fix CI lint#153
Ckk3 wants to merge 6 commits intogazorby:mainfrom
Ckk3:fix/lint-import-sorting

Conversation

@Ckk3
Copy link
Copy Markdown
Contributor

@Ckk3 Ckk3 commented Mar 4, 2026

Description

Fix CI lint failures caused by incorrect import sorting (I001 errors) and tool version drift between local and CI environments.

Root cause: A stale .ruff_cache locally masked import sorting errors. Ruff auto-detected strawberry as first-party (due to __pycache__ artifacts in src/strawchemy/strawberry/), while CI correctly classified it as third-party.

Changes:

  • Fix import sorting across 84 files — properly separate strawberry (third-party) from strawchemy (first-party)
  • Pin ruff version in pyproject.toml (>=0.14.10,<0.15)
  • Pin mise version in CI to 2025.12.12 (matching tools/mise wrapper)
  • Fix pre-commit hooks: bump ruff-pre-commit to v0.14.10, use tools/mise path, fix language: system
  • Fix render:usage task to use tools/mise

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

N/A

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Summary by CodeRabbit

  • Chores
    • Updated development tooling and CI caching behavior to standardize build/lint workflows and cache keys.
    • Adjusted lint dependency constraints and broadened tooling source paths for more consistent checks.
  • Documentation
    • Added documentation for a new pre-commit lint/format task to guide contributors.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

This PR updates CI cache identifiers, replaces remote pre-commit hooks with local/system invocations, adds a ruff pre-commit task, adjusts mise task invocations to use tools/mise, and tightens ruff dependency and project source/exclude settings in tooling configs.

Changes

Cohort / File(s) Summary
CI Cache
.github/workflows/ci.yaml
Changed cache key/restore-keys from noxnox-v2 for Pip and nox caching steps.
Pre-commit hooks
.pre-commit-config.yaml
Replaced external unasyncd and ruff-pre-commit hooks with repo: local hooks; switched hook commands to use uv run / tools/mise and language: system; set pass_filenames: false and require_serial: true for relevant hooks.
Task runner (mise)
mise.toml, tasks.md
Added tasks."ruff:pre-commit" task running uv run ruff check --fix and uv run ruff format; updated render:usage task to run via tools/mise; documented new ruff:pre-commit in tasks.md.
Project metadata
pyproject.toml
Pinned ruff to >=0.14.10,<0.15; expanded tool.mise.sources from ["src/strawchemy","tests"]["src","tests"]; added __pycache__ to exclusions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through CI keys and hooks so neat,

swapped remote scripts for local feet,
pinned Ruff’s version, formatted with care,
tools now run from tools/ everywhere,
carrots and commits in tidy retreat. 🥕

🚥 Pre-merge checks | ✅ 3
✅ 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 accurately describes the main changes: fixing import sorting issues and pinning tool versions to resolve CI lint failures.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.28%. Comparing base (fe8ade9) to head (4dcc55f).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #153   +/-   ##
=======================================
  Coverage   94.28%   94.28%           
=======================================
  Files          69       69           
  Lines        5814     5814           
  Branches      770      770           
=======================================
  Hits         5482     5482           
  Misses        190      190           
  Partials      142      142           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Ckk3 Ckk3 changed the title fix: sort imports across codebase to pass CI lint checks fix: correct import sorting and pin tool versions to fix CI lint Mar 4, 2026
Ckk3 added 3 commits March 4, 2026 19:20
…classification

The ruff `src = ["src/strawchemy"]` setting caused ruff to auto-detect
subdirectories like `sqlalchemy/` and `strawberry/` (from __pycache__)
as first-party packages. Changed to `src = ["src"]` so only `strawchemy`
is detected as a source package. Also pinned ruff in pre-commit unasyncd
hook to prevent version drift.
@Ckk3 Ckk3 marked this pull request as ready for review March 5, 2026 14:27
Copy link
Copy Markdown
Contributor

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.pre-commit-config.yaml:
- Line 59: The YAML uses spaced bracket array syntax which triggers yamllint
`brackets` errors: update the entries for additional_dependencies to use compact
brackets without spaces (e.g., change additional_dependencies: [
"ruff>=0.14.10,<0.15" ] to additional_dependencies: ["ruff>=0.14.10,<0.15"]) and
make the same change for the other occurrence; ensure you only remove the space
after `[` and before `]` while keeping the string contents unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6c59009c-88d6-4b92-8a94-a0bddc589d9b

📥 Commits

Reviewing files that changed from the base of the PR and between fe8ade9 and 58590d5.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .github/workflows/ci.yaml
  • .pre-commit-config.yaml
  • mise.toml
  • pyproject.toml

Comment thread .pre-commit-config.yaml Outdated
hooks:
- id: unasyncd
additional_dependencies: [ "ruff" ]
additional_dependencies: [ "ruff>=0.14.10,<0.15" ]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix YAML bracket spacing to clear lint errors.

Line 59 and Line 76 use spaced bracket style that triggers YAMLlint brackets errors.

Proposed fix
-        additional_dependencies: [ "ruff>=0.14.10,<0.15" ]
+        additional_dependencies: ["ruff>=0.14.10,<0.15"]
...
-        types: [ python ]
+        types: [python]

Also applies to: 76-76

🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 59-59: too many spaces inside brackets

(brackets)


[error] 59-59: too many spaces inside brackets

(brackets)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.pre-commit-config.yaml at line 59, The YAML uses spaced bracket array
syntax which triggers yamllint `brackets` errors: update the entries for
additional_dependencies to use compact brackets without spaces (e.g., change
additional_dependencies: [ "ruff>=0.14.10,<0.15" ] to additional_dependencies:
["ruff>=0.14.10,<0.15"]) and make the same change for the other occurrence;
ensure you only remove the space after `[` and before `]` while keeping the
string contents unchanged.

Comment thread .pre-commit-config.yaml Outdated
hooks:
- id: unasyncd
additional_dependencies: [ "ruff" ]
additional_dependencies: [ "ruff>=0.14.10,<0.15" ]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Version constraint should be in sync with pyproject.toml

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh I didnt saw that, I will fix it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed 4dcc55f

Comment thread .pre-commit-config.yaml Outdated
additional_dependencies: [ "ruff" ]
additional_dependencies: [ "ruff>=0.14.10,<0.15" ]

- repo: https://github.com/charliermarsh/ruff-pre-commit
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We should also replace this hook with a system one, invoking mise targets

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think is a nice improvement, I will add it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added 4dcc55f

Comment thread .pre-commit-config.yaml
name: lint
entry: mise run lint:pre-commit
language: python
entry: tools/mise run lint:pre-commit
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This should not be needed, as mise is already installed by the gh action

Copy link
Copy Markdown
Contributor Author

@Ckk3 Ckk3 Mar 31, 2026

Choose a reason for hiding this comment

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

Since this repo already have a mise in this folder I thought will be nice to already use it in CI and in local env.
What do you think about it?

Copy link
Copy Markdown
Contributor

@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

♻️ Duplicate comments (2)
.pre-commit-config.yaml (2)

55-63: ⚠️ Potential issue | 🟡 Minor

Fix YAML bracket spacing to pass lint.

The YAML uses spaced brackets [ python ] which triggers YAMLlint errors. Use compact brackets without spaces.

Proposed fix
-        types: [ python ]
+        types: [python]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.pre-commit-config.yaml around lines 55 - 63, Update the YAML for the
"unasyncd" pre-commit hook so the types list uses compact bracket spacing
(remove the spaces inside the brackets) to satisfy yamllint; specifically edit
the hook with id "unasyncd" (entry "uv run unasyncd") and change the types value
from "[ python ]" to "[python]" (or alternatively convert to a multi-line YAML
sequence) so the linter no longer flags bracket spacing.

65-73: ⚠️ Potential issue | 🟡 Minor

Fix bracket spacing and consolidate local hooks.

Same bracket spacing issue as above. Additionally, consider consolidating the three repo: local sections (unasyncd, ruff, lint) into a single repo: local block with multiple hooks for better maintainability.

Proposed fix for bracket spacing
-        types: [python]
+        types: [python]

Wait, line 71 shows types: [ python ] with spaces - fix to:

-        types: [ python ]
+        types: [python]
Optional consolidation of local hooks
  - repo: local
    hooks:
      - id: unasyncd
        name: unasyncd
        entry: uv run unasyncd
        language: system
        types: [python]
        pass_filenames: false
        require_serial: true
      - id: ruff
        name: ruff
        entry: tools/mise run ruff:pre-commit
        language: system
        types: [python]
        pass_filenames: false
        require_serial: true
      - id: lint
        name: lint
        entry: tools/mise run lint:pre-commit
        language: system
        types: [python]
        pass_filenames: false
        require_serial: true
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.pre-commit-config.yaml around lines 65 - 73, Fix the bracket spacing by
changing occurrences like types: [ python ] to types: [python] and consolidate
the separate "repo: local" blocks into a single "repo: local" block containing
multiple hook entries (include hooks for id: unasyncd, id: ruff, and id: lint)
so each hook preserves its fields (name, entry, language, types: [python],
pass_filenames: false, require_serial: true); ensure each hook uses the correct
entry values (e.g., "uv run unasyncd", "tools/mise run ruff:pre-commit",
"tools/mise run lint:pre-commit") and keep all existing settings when merging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.pre-commit-config.yaml:
- Around line 79-83: Fix the bracket spacing for the pre-commit hook's types
list: locate the block with the "types:" key (the entry using tools/mise run
lint:pre-commit) and remove the extra space inside the square brackets so it
reads types: [python] (or use a quoted single-item list like types: ["python"])
to match the project's YAML style.

---

Duplicate comments:
In @.pre-commit-config.yaml:
- Around line 55-63: Update the YAML for the "unasyncd" pre-commit hook so the
types list uses compact bracket spacing (remove the spaces inside the brackets)
to satisfy yamllint; specifically edit the hook with id "unasyncd" (entry "uv
run unasyncd") and change the types value from "[ python ]" to "[python]" (or
alternatively convert to a multi-line YAML sequence) so the linter no longer
flags bracket spacing.
- Around line 65-73: Fix the bracket spacing by changing occurrences like types:
[ python ] to types: [python] and consolidate the separate "repo: local" blocks
into a single "repo: local" block containing multiple hook entries (include
hooks for id: unasyncd, id: ruff, and id: lint) so each hook preserves its
fields (name, entry, language, types: [python], pass_filenames: false,
require_serial: true); ensure each hook uses the correct entry values (e.g., "uv
run unasyncd", "tools/mise run ruff:pre-commit", "tools/mise run
lint:pre-commit") and keep all existing settings when merging.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 827fe0cf-ef20-4455-bfb1-9b240de5b566

📥 Commits

Reviewing files that changed from the base of the PR and between 58590d5 and 4dcc55f.

📒 Files selected for processing (3)
  • .pre-commit-config.yaml
  • mise.toml
  • tasks.md

Comment thread .pre-commit-config.yaml
Comment on lines +79 to 83
entry: tools/mise run lint:pre-commit
language: system
types: [ python ]
pass_filenames: false
require_serial: true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix bracket spacing.

Same bracket spacing issue at line 81.

Proposed fix
-        types: [ python ]
+        types: [python]
📝 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
entry: tools/mise run lint:pre-commit
language: system
types: [ python ]
pass_filenames: false
require_serial: true
entry: tools/mise run lint:pre-commit
language: system
types: [python]
pass_filenames: false
require_serial: true
🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 81-81: too many spaces inside brackets

(brackets)


[error] 81-81: too many spaces inside brackets

(brackets)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.pre-commit-config.yaml around lines 79 - 83, Fix the bracket spacing for
the pre-commit hook's types list: locate the block with the "types:" key (the
entry using tools/mise run lint:pre-commit) and remove the extra space inside
the square brackets so it reads types: [python] (or use a quoted single-item
list like types: ["python"]) to match the project's YAML style.

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.

2 participants