Skip to content

Enable ruff rule RUF - #2457

Merged
MaartenGr merged 2 commits into
MaartenGr:masterfrom
afuetterer:ruff-ruf
Dec 3, 2025
Merged

MaartenGr merged 2 commits into
MaartenGr:masterfrom
afuetterer:ruff-ruf

Conversation

@afuetterer

@afuetterer afuetterer commented Nov 12, 2025 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Discussion at #2450

  1. Mostly it is something like this:
nr_topics: Union[int, str] = None,

-->

nr_topics: Union[int, str] | None = None,

If you add the type hint Union[int, str] you should not use a default value of None.

  1. It also sorts entries in __all__ alphabetically.

  2. This RUF015 unnecessary-iterable-allocation-for-first-element might actually be a little faster. You don't need to convert result of zip to list to access first entry.

Summary:

$ ruff check --statistics
116     RUF013  [ ] implicit-optional
 18     RUF015  [ ] unnecessary-iterable-allocation-for-first-element
  3     RUF022  [*] unsorted-dunder-all
  2     RUF005  [ ] collection-literal-concatenation
  1     RUF010  [*] explicit-f-string-type-conversion
  1     RUF059  [ ] unused-unpacked-variable

Before submitting

  • This PR fixes a typo or improves the docs (if yes, ignore all other checks!).
  • Did you read the contributor guideline?
  • Was this discussed/approved via a Github issue? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes (if applicable)?
  • Did you write any new necessary tests?

@afuetterer
afuetterer marked this pull request as draft November 12, 2025 08:07
@afuetterer
afuetterer marked this pull request as ready for review November 12, 2025 08:14
@MaartenGr

Copy link
Copy Markdown
Owner

Looks great to me! Thanks again for the PR.

@MaartenGr
MaartenGr merged commit adf1bdc into MaartenGr:master Dec 3, 2025
5 checks passed
@afuetterer
afuetterer deleted the ruff-ruf branch December 3, 2025 13:33
@roli-lpci roli-lpci mentioned this pull request Feb 25, 2026
2 of 5 tasks
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