Skip to content

Fix the lint failures that are failing CI on main (ruff + clippy)#305

Open
HarperZ9 wants to merge 2 commits into
python-grimp:mainfrom
HarperZ9:fix/ruff-furb110-lint
Open

Fix the lint failures that are failing CI on main (ruff + clippy)#305
HarperZ9 wants to merge 2 commits into
python-grimp:mainfrom
HarperZ9:fix/ruff-furb110-lint

Conversation

@HarperZ9

@HarperZ9 HarperZ9 commented Jun 30, 2026

Copy link
Copy Markdown

What

The Lint and check docs build job is red on main, which (because it shares the workflow with the test matrix and fail-fast is on) cancels the test jobs too, so every PR shows all-red even though the Python suite passes. The lint job runs just lint = lint-python then lint-rust, and both halves currently fail from independent tool version bumps:

1. Python: ruff FURB110

ruff.toml uses lint.select = ["ALL"], which enables FURB110 ("Replace ternary if expression with or operator"), flagging:

FURB110  tests/adaptors/filesystem.py:51:28
FURB110  tests/adaptors/filesystem.py:52:44

Fix: replace x if x else {} with the idiomatic x or {} (the rule's prescribed fix; semantically identical for the falsy-to-{} default).

2. Rust: clippy collapsible_match

With the Python lint fixed, just lint proceeds to lint-rust, where cargo clippy --all-targets --all-features -- -D warnings fails on clippy 1.96's collapsible_match in rust/src/import_parsing.rs:131: the Expr::Attribute match arm wraps an if expr.attr.id == "TYPE_CHECKING" { ... } else { walk_stmt(...) }.

Fix: collapse it into a pattern guard (clippy's own suggested fix). The else branch was identical to the _ => fallthrough, so when the guard is false the statement is still walked. Behavior is unchanged.

Verification

Python, with the pinned ruff==0.14.8:

$ ruff check                # All checks passed!
$ ruff format --check       # 64 files already formatted

Rust, with the CI toolchain rust 1.96.0:

$ cargo fmt --check                                          # clean
$ cargo clippy --all-targets --all-features -- -D warnings   # clean
$ cargo check --release --all-targets                        # clean

On this PR the Lint and check docs build job now passes, which is the blocker that was cancelling the test matrix.

Note on the remaining red

After the lint job goes green the test matrix runs, and Run tests for Python 3.10, macos-latest fails during the maturin/pyo3 extension build with a macOS linker error (undefined _PyExc_* symbols, clang: linker command failed). That is a native-build/environment issue, not something this lint-only change touches, and I do not have permission to re-run jobs on this repo. A maintainer re-run (or a look at the macOS pyo3 build) would confirm.


Disclosure: authored with AI assistance (Claude), reviewed and verified before submitting. Happy to adjust if you would rather handle either lint via config (pinning the tools or scoping the rules) instead.

`lint.select = ["ALL"]` enables FURB110, which flags the
`x if x else {}` ternary in `tests/adaptors/filesystem.py` and fails
`ruff check` on main. Because the lint job runs in the same workflow as
the test matrix, its failure cancels every test job via fail-fast, so
all CI checks show red even though the suite itself passes.

Replace the two ternaries with the idiomatic `or` operator (the rule's
own prescribed fix), which is semantically identical for the falsy-to-{}
default. `ruff check` and `ruff format --check` are both clean with the
pinned ruff 0.14.8.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codspeed-hq

codspeed-hq Bot commented Jun 30, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 23 skipped benchmarks1


Comparing HarperZ9:fix/ruff-furb110-lint (ab39a71) with main (977b7f0)

Open in CodSpeed

Footnotes

  1. 23 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

After the ruff fix, `just lint` advances to `lint-rust`, where
`cargo clippy -- -D warnings` fails on clippy 1.96's collapsible_match in
`rust/src/import_parsing.rs`: the `Expr::Attribute` match arm wraps an
`if expr.attr.id == "TYPE_CHECKING" { ... } else { walk_stmt(...) }`.

Collapse it into a pattern guard (clippy's own suggested fix). The else
branch was identical to the `_ =>` fallthrough, so when the guard is false
the statement is still walked via that arm. Behavior is unchanged.

Verified with the CI toolchain (rust 1.96.0):
  cargo fmt --check        -> clean
  cargo clippy ... -D warnings -> clean

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@HarperZ9 HarperZ9 changed the title Fix ruff FURB110 lint failure that is failing CI on main Fix the lint failures that are failing CI on main (ruff + clippy) Jun 30, 2026
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.

1 participant