Skip to content
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

Apply assorted ruff rules #13093

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

DimitriPapadopoulos
Copy link
Contributor

Subject: apply new ruff rules

Feature or Bugfix

  • Refactoring

ISC001 Implicitly concatenated string literals on one line
PYI018 Private TypeVar is never used
@@ -92,7 +92,7 @@ def match(self, value: str | list | tuple) -> bool:


class _Opt:
__slots__ = 'default', 'rebuild', 'valid_types', 'description'
__slots__ = 'default', 'description', 'rebuild', 'valid_types'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? The slots are in definition order

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed debatable. The rationale for RUF023 is:

Checks for __slots__ definitions that are not ordered according to a natural sort.

Consistency is good. Use a common convention for this special variable to make your code more readable and idiomatic.

@AA-Turner
Copy link
Member

PRs which apply multiple rules at once make history harder to decipher, perhaps we could split to one PR per rule, or per group of rules.

A

@DimitriPapadopoulos
Copy link
Contributor Author

Alternatively, merge without squashing. The PR is already split into multiple commits.

PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal['a', 'b']`
RUF022 `__all__` is not sorted
RUF023 `__slots__` is not sorted
@AA-Turner
Copy link
Member

AA-Turner commented Oct 31, 2024

Merge commits are disabled for this repo -- there's no option to select it. This is to preserve linear history. (I do appreciate the effort to split into individual commits, though, thank you)

@jayaddison jayaddison added internals:refactoring python Pull requests that update Python code labels Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internals:refactoring python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants