Skip to content

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

Open
d-v-b wants to merge 1 commit 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 1 commit into
zarr-developers:mainfrom
d-v-b:claude/codebase-linting-ruff-d0e185

Conversation

@d-v-b

@d-v-b d-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)

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
@codecov

codecov Bot 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 93.91%. Comparing base (63fc294) to head (f4671c2).

Files with missing lines Patch % Lines
src/zarr/storage/_common.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4213   +/-   ##
=======================================
  Coverage   93.91%   93.91%           
=======================================
  Files          91       91           
  Lines       12678    12677    -1     
=======================================
  Hits        11906    11906           
+ Misses        772      771    -1     
Files with missing lines Coverage Δ
src/zarr/api/synchronous.py 92.95% <ø> (ø)
src/zarr/codecs/sharding.py 96.17% <100.00%> (ø)
src/zarr/core/array.py 97.85% <100.00%> (ø)
src/zarr/core/dtype/common.py 86.20% <100.00%> (ø)
src/zarr/core/sync.py 94.23% <100.00%> (ø)
src/zarr/testing/store.py 98.91% <100.00%> (ø)
src/zarr/testing/strategies.py 95.42% <100.00%> (ø)
src/zarr/storage/_common.py 93.00% <0.00%> (+0.46%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

pass ruff >= 0.16

1 participant