Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork10.9k
MNT: Enforce ruff/Perflint rules (PERF)#28970
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes from1 commit
54be49e
7c427be
c21a886
92accad
e4e0c83
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
PERF102 When using only the values of a dict use the `values()` methodPERF102 When using only the keys of a dict use the `keys()` method
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -124,7 +124,7 @@ def assert_equal(actual, desired, err_msg=''): | ||
for k, i in desired.items(): | ||
if k not in actual: | ||
raise AssertionError(f"{k} not in {actual}") | ||
assert_equal(actual[k],i, f'key={k!r}\n{err_msg}') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This change is not the one suggested by the latest version of ruff (on my system at least). Instead of the change here we could also write this as
ContributorAuthor
| ||
return | ||
# Case #2: lists ..... | ||
if isinstance(desired, (list, tuple)) and isinstance(actual, (list, tuple)): | ||
@@ -162,12 +162,12 @@ def fail_if_equal(actual, desired, err_msg='',): | ||
for k, i in desired.items(): | ||
if k not in actual: | ||
raise AssertionError(repr(k)) | ||
fail_if_equal(actual[k],i, f'key={k!r}\n{err_msg}') | ||
return | ||
if isinstance(desired, (list, tuple)) and isinstance(actual, (list, tuple)): | ||
fail_if_equal(len(actual), len(desired), err_msg) | ||
for k, iinenumerate(desired): | ||
fail_if_equal(actual[k],i, f'item={k!r}\n{err_msg}') | ||
return | ||
if isinstance(actual, np.ndarray) or isinstance(desired, np.ndarray): | ||
return fail_if_array_equal(actual, desired, err_msg) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -356,13 +356,13 @@ def assert_equal(actual, desired, err_msg='', verbose=True, *, strict=False): | ||
for k, i in desired.items(): | ||
if k not in actual: | ||
raise AssertionError(repr(k)) | ||
assert_equal(actual[k],i, f'key={k!r}\n{err_msg}', | ||
verbose) | ||
return | ||
if isinstance(desired, (list, tuple)) and isinstance(actual, (list, tuple)): | ||
assert_equal(len(actual), len(desired), err_msg, verbose) | ||
for k, iinenumerate(desired): | ||
assert_equal(actual[k],i, f'item={k!r}\n{err_msg}', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This is less readable than before, but maybe we have to accept these changes to have the benefits of ruff. Renaming the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It's very much out-of-scope here, but generally speaking it's preferable to use parametric tests instead of putting assertions in a for-loop 🤷🏻 But even so, I agree that it wouldn't hurt to rename ContributorAuthor
| ||
verbose) | ||
return | ||
from numpy import imag, iscomplexobj, real | ||