- Notifications
You must be signed in to change notification settings - Fork25
Allow settingpylsp.plugins.ruff.format
to["ALL"]
#101
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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
In this case, the ignore will take precedence and setting`pylsp.plugins.ruff.format` to `["ALL"]` will do nothing.
Update existing test text to be compatible with the case that a formatis run with `format` set to `["ALL"]`.
@@ -142,7 +142,7 @@ def pylsp_format_document(workspace: Workspace, document: Document) -> Generator | |||
# specifying `format = ["I"]` to get import sorting as part of formatting. | |||
new_text = run_ruff( | |||
settings=PluginSettings( | |||
ignore=["ALL"], | |||
ignore=["ALL"] if "ALL" not in settings.format else [], |
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 is admittedly a bit of a quick and dirty patch; would it be preferred to track this condition when the settings are parsed?
@@ -121,3 +127,22 @@ def test_ruff_format_and_sort_imports(workspace): | |||
) | |||
got = run_plugin_format(workspace, doc) | |||
assert want == got | |||
def test_ruff_format_via_all(workspace): |
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 is somewhat of a fragile thing to test since it's at the mercy of whatever rules ruff might add. The tested text might be reasonably robust, but it also might be best to just leave this out.
I'm a new user of ruff, so apologies if this is not intended usage!
When setting up my ruff config, I thought it might be fun to aggressively format using all of ruff's rules in the absence of any project settings.
However, it appears that the
ignore
option dominates theselect
option forruff check
if the same rule code is specified in each. Thus, the plugin will not currently work as expected ifpylsp.plugins.ruff.format
is set to["ALL"]
.