-
Notifications
You must be signed in to change notification settings - Fork 79
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
Add some ruff rules for pyupgrade #183
Conversation
If you want to submit the patch related code style issue, would you like to submit the patch including the CI works? |
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.
Would it be possible to exclude changes converting code to "expr1 if test else expr2"?
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.
@corona10: What do you think of this change?
This change combines many different changes. Some of them are uncontroversial, I have an opinion on the others :-) |
I understand. These PRs are super easy to create locally with syntax like: |
I'm fine with these changes, coming from the old time when pyperf worked on Python 2:
|
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.
Merged, thanks. |
%
ruff check --select=UP --ignore=UP015,UP031 --statistics | sort -k2
%
ruff rule UP024
os-error-alias (UP024)
Derived from the pyupgrade linter.
Fix is always available.
What it does
Checks for uses of exceptions that alias
OSError
.Why is this bad?
OSError
is the builtin error type used for exceptions that relate to theoperating system.
In Python 3.3, a variety of other exceptions, like
WindowsError
werealiased to
OSError
. These aliases remain in place for compatibility witholder versions of Python, but may be removed in future versions.
Prefer using
OSError
directly, as it is more idiomatic and future-proof.Example
Use instead:
References
OSError