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
MAINT: lint: enable UP rules #19516
MAINT: lint: enable UP rules #19516
Conversation
If there is agreement on this change, we should add a commit with an entry in |
Yes, I didn't yet in anticipation of a force push (which was immediately necessary since I forgot to |
CI is green (apart from the broken docs build). I've noticed some formatting issues (multiline strings off by 1 space, closing brackets on a new line). These will probably have to be looked at manually unfortunately. |
It would difficult to catch them later if we lose the I see quite a number of ('some long string'
'') # <- This looks like a tool bug to me instances and I think ruff should be fixed about that. |
IIUC this is because the linter is intended to be used in tandem with a formatter (i.e. linter is minimal in formatting changes). This is difficult for SciPy to adopt short of formatting the entire codebase (far too disruptive). Edit: I'm happy to do a full pass through the diff to fix these. I'm quite busy right now so it will take a little while. |
Docs build failure is fixed in main, not related to this PR. |
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 skimmed this, mostly trusting that the automated linting didn't make any logical errors. I noted a few of the ugly things I found toward the top, but they are quite common, so I didn't continue, since we are supposed to rush this. Feel free to ignore these suggestions because they're not nearly complete.
The one thing I'll ask is why the lint check is passing, because some of these lines are far longer than the limit. Is that check not enabled here?
I thought this was related to the line length stuff, but I guess not. We will need a separate pass for that, I suppose.
Thanks Matt, I added the |
astral-sh/ruff#8683 at least some of the formatting issues will be fixed in the next ruff release. I might wait for that and remake the PR (as long as a force push wouldn't be too disruptive?) I'm also inclined to wait for gh-19529 in case anything else arises from there. |
@lucascolley In the interest of time, consider using ruff from their main branch? |
down to 22 errors which need to be fixed manually. There may be more once I rebase for gh-19529. |
A slight change is needed for |
1df50b1
to
213ce8d
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.
Changes seem reasonable but might be useful for another pair of eyes as it is easy to miss stuff
raise ValueError("f(a) and f(b) must have different signs, but " | ||
"f({:e})={:e}, f({:e})={:e} ".format(a, fa, b, fb)) | ||
f"f({a:e})={fa:e}, f({b:e})={fb:e} ") |
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 the alignment here correct?
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.
Ah no, good spot 👍
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.
On second thought I think this is correct.
OK, let's get this in before it goes stale. Do you want to make the .git-blame-ignore-revs commit(s)? |
👍 I'll address Jake's comment, squash down to 1 clean-up commit and add it to the ignored revisions (tomorrow). Thanks all for the quick review! |
@stefanv good to go once CI is okay? |
I see the same failure on PRs recently merged to main, so let's get this in before it becomes impossible to merge. |
Thanks very much @lucascolley. |
thanks all! I imagine there isn't appetite for any more big changes soon, but if there are any other rules which you think may be worth our time @stefanv, let me know and I'm happy to look into them. |
Reference issue
#18353 (comment)
What does this implement/fix?
Quoting @stefanv :
Additional information
The vast majority of these changes were made automatically by Ruff's
--fix
, with the rest (changing fromUnion
typing and toyield from
) made by me.Due to the automatic fixes, further (minor) style cleanups are possible here, but I don't know if they're worth the effort (or worth delaying this PR for).
The blame ignore will be added once this is ready.