Skip to content

Apply assorted ruff preview rules #10465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 30, 2025
Merged

Conversation

DimitriPapadopoulos
Copy link
Contributor

  • Closes #xxxx
  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst
  • New functions/methods are listed in api.rst

B909 Mutation to loop iterable during iteration
PYI059 `Generic[]` should always be the last base class
PLC0207 Accessing only the first or last element of `str.split()` without setting `maxsplit=1`
PLW0108 Lambda may be unnecessary; consider inlining inner function
FURB110 Replace ternary `if` expression with `or` operator
FURB171 Membership test against single-item container
@github-actions github-actions bot added topic-backends topic-documentation topic-plotting topic-cftime topic-zarr Related to zarr storage library topic-DataTree Related to the implementation of a DataTree class topic-typing io topic-NamedArray Lightweight version of Variable labels Jun 29, 2025
The initial intent was probably `value.dtype.kind in "cf"`.

In any case, this is a no-op because `value.dtype.kind == "O"`.

So remove the test altogether.
RUF036 `None` not at the end of the type annotation.
@DimitriPapadopoulos DimitriPapadopoulos marked this pull request as ready for review June 29, 2025 11:15
@max-sixty
Copy link
Collaborator

lots of these are nice!

can we add the rules to pyproject and so add a ratchet?

@max-sixty max-sixty merged commit 7ea28b1 into pydata:main Jun 30, 2025
33 checks passed
@DimitriPapadopoulos DimitriPapadopoulos deleted the preview branch July 1, 2025 07:48
@DimitriPapadopoulos
Copy link
Contributor Author

I just tried the --preview once and addressed the issues that made some sense to me. I'm not sure if it's a good idea to set preview, it would pull other unstable rules that I would mostly ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io topic-backends topic-cftime topic-DataTree Related to the implementation of a DataTree class topic-documentation topic-NamedArray Lightweight version of Variable topic-plotting topic-typing topic-zarr Related to zarr storage library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants