Skip to content

Commit ed4ae39

Browse files
committed
add unfixable setting
1 parent 041c695 commit ed4ae39

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pylsp = {
5656
format = { "I" }, -- Rules that are marked as fixable by ruff that should be fixed when running textDocument/formatting
5757
severities = { ["D212"] = "I" }, -- Optional table of rules where a custom severity is desired
5858
unsafeFixes = false, -- Whether or not to offer unsafe fixes as code actions. Ignored with the "Fix All" action
59+
unfixable = { "F401" }, -- Rules that are excluded when checking the code actions (including the "Fix All" action)
5960

6061
-- Rules that are ignored when a pyproject.toml or ruff.toml is present:
6162
lineLength = 88, -- Line length to pass to ruff checking and formatting
@@ -140,7 +141,7 @@ The `Fix all` code action *only* consideres safe fixes.
140141
The log level can be set via the `cmd` option of `pylsp`:
141142

142143
```lua
143-
lspconfig.pylsp.setup {
144+
vim.lsp.config("pylsp", {
144145
cmd = {"pylsp", "-vvv", "--log-file", "/tmp/lsp.log"},
145146
settings = {
146147
pylsp = {
@@ -151,5 +152,5 @@ lspconfig.pylsp.setup {
151152
}
152153
}
153154
}
154-
}
155+
})
155156
```

pylsp_ruff/plugin.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@ def build_check_arguments(
621621
if settings.unsafe_fixes:
622622
args.append("--unsafe-fixes")
623623

624+
if settings.unfixable:
625+
args.append(f"--unfixable={','.join(settings.unfixable)}")
626+
624627
if settings.exclude:
625628
args.append(f"--exclude={','.join(settings.exclude)}")
626629

@@ -723,8 +726,8 @@ def load_settings(workspace: Workspace, document_path: str) -> PluginSettings:
723726
724727
"""
725728
config = workspace._config
726-
_plugin_settings = config.plugin_settings("ruff", document_path=document_path)
727-
plugin_settings = converter.structure(_plugin_settings, PluginSettings)
729+
plugin_settings = config.plugin_settings("ruff", document_path=document_path)
730+
plugin_settings = converter.structure(plugin_settings, PluginSettings)
728731

729732
pyproject_file = find_parents(
730733
workspace.root_path, document_path, ["pyproject.toml"]

pylsp_ruff/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class PluginSettings:
2727
preview: bool = False
2828
unsafe_fixes: bool = False
2929

30+
unfixable: Optional[List[str]] = None
31+
3032
severities: Optional[Dict[str, str]] = None
3133

3234
target_version: Optional[str] = None

0 commit comments

Comments
 (0)