Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
willjow wants to merge2 commits intopython-lsp:main
base:main
Choose a base branch
Loading
fromwilljow:allow-format-ALL

Conversation

willjow
Copy link

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 theignore 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"].

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 [],
Copy link
Author

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):
Copy link
Author

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.

@willjowwilljow marked this pull request as ready for reviewOctober 25, 2024 04:44
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@willjow

[8]ページ先頭

©2009-2025 Movatter.jp