-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
top: Fix ruff rules: E721,F524,F541,F632 #10991
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
top: Fix ruff rules: E721,F524,F541,F632 #10991
Conversation
Code size report:
|
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #10991 +/- ##
=======================================
Coverage 98.50% 98.50%
=======================================
Files 155 155
Lines 20549 20549
=======================================
Hits 20241 20241
Misses 308 308 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
fed237f
to
22bf8fd
Compare
extmod/uasyncio/funcs.py
Outdated
@@ -123,7 +123,7 @@ def done(t, er): | |||
|
|||
# Either this gather was cancelled, or one of the sub-tasks raised an exception with | |||
# return_exceptions==False, so reraise the exception here. | |||
if state is not 0: | |||
if state != 0: |
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.
state
can be an integer or an exception type, so that's why is not
is used
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.
is not 0
only works because of the implementation detail of MP_SMALL_INT but in general is
should not be used with ints.
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.
Yes you are right. So I'll need to check in detail what happens for state != 0
when state is an exception instance.
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.
Won't if state:
work since 0 is falsy but any exception will be truthy?
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.
Yes that's a good idea. At this point state
is either 0
or an exception instance (because in the latter case it's raising it).
shared/memzip/make-memzip.py
Outdated
@@ -36,7 +36,7 @@ def create_c_from_file(c_filename, zip_filename): | |||
break | |||
print(' ', end='', file=c_file) | |||
for byte in buf: | |||
if type(byte) is types.StringType: | |||
if type(byte) is types.StringType: # noqa: E721 |
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.
maybe this can be changed to use isinstance
?
22bf8fd
to
86f3320
Compare
86f3320
to
97de2db
Compare
This fixes: - type-comparison (E721): do not compare types, use isinstance(). - string-dot-format-missing-arguments (F524): .format call is missing argument(s) for placeholder(s): {message}. - f-string-missing-placeholders (F541). - is-literal (F632): Use != to compare constant literals. The last one is fixed by just comparing for truthfulness of `state`.
97de2db
to
79e5747
Compare
I updated the commit message with more detail. |
Thanks for the fixes! |
As an alternative, you can also do |
Fixes for:
isinstance()
.format
call is missing argument(s) for placeholder(s): {message}==
to compare constant literals!=
to compare constant literalsWhen we have a
pyproject.toml
(#10977) we will need to ignore some test files that directly check these issues.