Skip to content

chore: bump ruff to 0.16.0 and fix new default-rule violations - #4213

Open
d-v-b wants to merge 4 commits into
zarr-developers:mainfrom
d-v-b:claude/codebase-linting-ruff-d0e185
Open

chore: bump ruff to 0.16.0 and fix new default-rule violations#4213
d-v-b wants to merge 4 commits into
zarr-developers:mainfrom
d-v-b:claude/codebase-linting-ruff-d0e185

Conversation

@d-v-b

@d-v-bd-v-b commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Ruff 0.16 is stricter. this PR makes our codebase pass the new checks. closes#4212

A few code changes:

  • StorePath.eq narrows a blind 'except Exception: pass' to 'except AttributeError: return False' (BLE001/S110)
  • reset_resources_after_fork drops 'loop' and 'iothread' from the global statement; they are mutated in place, not rebound (PLW0602)
  • subprocess.run calls in tests pass check=False explicitly since they assert on returncode themselves (PLW1510)
  • intentional patterns (returning the caught exception in sync._runner, self-equality assertion in the store test suite) get targeted noqa comments (BLE001/PLR0124)

Assisted-by: ClaudeCode:claude-fable-5

For reviewers

Have a look at the changes and new rules and judge if they are acceptable

Author attestation

  • I am a human, these are my changes, and I have reviewed and understood every change and can explain why each is correct.

TODO

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/user-guide/*.md
  • Changes documented as a new file in changes/
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@codecov

codecovBot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.00%. Comparing base (5a4767b) to head (78b349f).

Files with missing linesPatch %Lines
src/zarr/storage/_common.py0.00%2 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #4213 +/- ##
=======================================
Coverage 93.99% 94.00% =======================================
Files 91 91 Lines 12795 12794 -1 =======================================
Hits 12027 12027 + Misses 768 767 -1 
Files with missing linesCoverage Δ
src/zarr/api/synchronous.py92.95% <ø> (ø)
src/zarr/codecs/sharding.py96.17% <100.00%> (ø)
src/zarr/core/array.py97.85% <100.00%> (ø)
src/zarr/core/dtype/common.py86.20% <100.00%> (ø)
src/zarr/core/sync.py94.23% <100.00%> (ø)
src/zarr/testing/store.py98.33% <100.00%> (ø)
src/zarr/testing/strategies.py95.42% <100.00%> (ø)
src/zarr/storage/_common.py93.00% <0.00%> (+0.46%)⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@d-v-b
d-v-b requested a review from maxrjonesJuly 30, 2026 06:41
Ruff 0.16.0 enables a much larger default rule set (flake8-bugbear,
blind-except, bandit subset, pylint subset, etc.) and formats Python
code blocks inside Markdown files. This bumps the pin in pyproject.toml
and pre-commit, applies the automatic fixes (RUF036 None-at-end-of-union,
RUF100 unused noqa, PLR1716 chained comparison), and resolves the rest
by hand:
- StorePath.__eq__ narrows a blind 'except Exception: pass' to
'except AttributeError: return False' (BLE001/S110)
- reset_resources_after_fork drops 'loop' and 'iothread' from the
global statement; they are mutated in place, not rebound (PLW0602)
- subprocess.run calls in tests pass check=False explicitly since they
assert on returncode themselves (PLW1510)
- intentional patterns (returning the caught exception in sync._runner,
self-equality assertion in the store test suite) get targeted noqa
comments (BLE001/PLR0124)
Assisted-by: ClaudeCode:claude-fable-5
@d-v-b
d-v-bforce-pushed the claude/codebase-linting-ruff-d0e185 branch from a937f21 to 54624c5CompareJuly 30, 2026 12:35
@maxrjones
maxrjones enabled auto-merge (squash) August 6, 2026 19:19
Sign up for freeto 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.

pass ruff >= 0.16

2 participants

@d-v-b@maxrjones