-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
Use ruff
to also sort imports
#3237
Use ruff
to also sort imports
#3237
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me.
I'd rather have these automagically sorted in a consistent manner aligned with python coding standards than having to figure it out myself.
…written elsewhere (e.g., the CPython repository)
I added back the missing import and also rewrote the method to how I've seen it typically typed out elsewhere, such as the CPython repository: https://github.com/search?q=repo%3Apython%2Fcpython%20%22classmethod(types.GenericAlias)%22&type=code |
Does the import sorting not also apply to stub files? |
Nope,
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM;
There's a little TODO still left:
|
I assumed that would be a separate PR, but I guess it could be put with this one for convenience, placing the large changes together. |
This configuration should properly configure the ruff configuration: [tool.ruff]
extend-exclude = [
"buildconfig/*.py", # *.pyi stub files still included
"docs/reST",
"setup.py",
] Alternatively, |
Both options have a flaw I dislike, with the exclude it's not being quite as specific, for example, if there were other That said, considering that the reason we don't want I did consult |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; thanks!
(Before merging, pull in from main and run pre-commit so that tests pass.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the PR 👍
Just a capability that was not being utilized (it was done before when we were using
black
+isort
)From
ruff
docs: