-
Notifications
You must be signed in to change notification settings - Fork 530
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
STY: Enforce ruff rules #3690
base: master
Are you sure you want to change the base?
STY: Enforce ruff rules #3690
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3690 +/- ##
==========================================
+ Coverage 70.84% 70.86% +0.01%
==========================================
Files 1277 1277
Lines 59118 59106 -12
Branches 9803 8586 -1217
==========================================
+ Hits 41884 41885 +1
- Misses 16067 16076 +9
+ Partials 1167 1145 -22 ☔ View full report in Codecov by Sentry. |
a6804a0
to
030f052
Compare
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.
10 comments, to avoid collapsing.
self.inputs.regularization_gradient_field_sigma, | ||
self.inputs.regularization_deformation_field_sigma, | ||
) | ||
return f"--regularization {self.inputs.regularization}[{self.inputs.regularization_gradient_field_sigma},{self.inputs.regularization_deformation_field_sigma}]" |
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.
This doesn't strike me as more readable. Could do something like:
return f"--regularization {self.inputs.regularization}[{self.inputs.regularization_gradient_field_sigma},{self.inputs.regularization_deformation_field_sigma}]" | |
gfsigma = self.inputs.regularization_gradient_field_sigma | |
dfsigma = self.inputs.regularization_deformation_field_sigma | |
return f"--regularization {self.inputs.regularization}[{gfsigma},{dfsigma}]" |
Alternately, we could use format strings sensibly using input_spec
fields and then trait_get()
to populate them:
return f"--regularization {self.inputs.regularization}[{self.inputs.regularization_gradient_field_sigma},{self.inputs.regularization_deformation_field_sigma}]" | |
fmt = "--regularization {regularization}[{regularization_gradient_field_sigma},{regularization_deformation_field_sigma}]" | |
return fmt.format(**self.inputs.trait_get()) |
I would do this throughout. I don't think f-strings are improving things here, even if they might be very slightly more efficient.
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.
I agree. I'm not very happy with these changes either. I can't decide whether I should disable UP0032 altogether and discard these changes, or apply the changes that make sense and silence the rest with noqa
. What would you do?
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.
We could do a per-file ignore, if it's only a couple files that get really ugly. Then we can revisit them separately or never. %
and str.format
aren't going away, so there's no time bomb if we end up just saying "ANTs is too special for UP032".
If it's broad, we could set the ignore to everything in "nipype/interfaces".
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.
@effigies I still need to review all the UP032 changes and undo bad fixes.
Just realized this is still in draft. Will hold off on further review for now. |
9aa4484
to
8da086b
Compare
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.
Small suggestions.
B007 Loop control variable not used within loop body Co-authored-by: Chris Markiewicz <[email protected]>
B015 Pointless comparison at end of function scope. Did you mean to return the expression result?
B018 Found useless expression. Either assign it to a variable or remove it.
E741 Ambiguous variable name
FURB154 Use of repeated consecutive `global`
PLE0101 Explicit return in `__init__`
PLE1205 Too many arguments for `logging` format string
PT006 Wrong type passed to first argument of `@pytest.mark.parametrize`; expected `tuple`
PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple`
PT014 Duplicate of test case in `@pytest_mark.parametrize`
Q000 Single quotes found but double quotes preferred
Q003 Change outer quotes to avoid escaping inner quotes
RUF100 Unused blanket `noqa` directive
UP008 Use `super()` instead of `super(__class__, self)`
UP032 Use f-string instead of `format` call Co-authored-by: Chris Markiewicz <[email protected]>
Disable some rules and postpone fixes.
8da086b
to
2fff982
Compare
Summary
Disable some rules and postpone fixes.
Requires #3689.