-
-
Notifications
You must be signed in to change notification settings - Fork 412
Run ruff format
#2697
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
Run ruff format
#2697
Conversation
Overall it doesn't look too bad, I'm for doing this move, being able to run |
Although I'm not really a fan of the black style (personal preference), there are some definite advantages to being able to run
Agreed. Now would be the best time (before any version 3.0 releases). It basically comes down to doing it now and then having to rebase the outstanding PRs, or to merge them first and then do a full conversion (reformatting) before any release. |
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 have to admit, this doesn't look as bad as I thought it would. Still some things that go against my personal preferences, but I don't think there are any show stoppers.
I haven't thought this through, but I wonder if we could retain much of our import formatting by running isort --fix
before running ruff format
?
You can't. Having both leads to inevitable conflicts. See thread: astral-sh/ruff#19532 |
I'm aware of that, but if the only difference is the addition/removal of blank lines then I still think there might be merit in my suggestion. For example, a user contributes code that includes: from PyQt6 import QtCore, QtWidgets, QtGui
import sys, os This is clearly not what we would like to see. Running import os
import sys
from PyQt6 import (
QtCore,
QtGui,
QtWidgets,
) This makes more sense for reviewing changes, but it isn't valid in ruff. If the file was then processed by The end result (after processing initially with As I said initially, I haven't thought this through (and I'll admit I'm not thoroughly familiar with ruff), but it seems that it might be a way to help automate the preferred formatting of imports to produce them in a (reproducable) sorted manner with no multiple iimports on a single line. What am I missing? |
# Conflicts: # picard/ui/metadatabox/__init__.py
Add trailing commas to preferred multi-line items
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 think most changes are fine, and we can deal with that. The one thing I really dislike is ruff's tendency to reformat some code that was intentionally broken over multiple lines, as e.g. some list comprehensions are.
The result in one line is often much less readable, and the dependence on code length can cause lines to easily toggle between multi and single line formatting on minor changes (e.g. variable name change). That can make diffs noisy.
But at least with the skip-magic-trailing-comma = false
it leaves some cases of intentional line splitting alone.
I'm still in favor of merging this. Having this in place makes things easier overall. And it allows new contributors to easily get their code formatted in a consistent way.
Very nice changes, thanks. Should reduce noise for incoming PR's. Next step we should add |
Summary
Problem
Solution
Action
Additional actions required: