8000 add extendSelect option · python-lsp/python-lsp-ruff@ad4b438 · GitHub
[go: up one dir, main page]

Skip to content

Commit ad4b438

Browse files
committed
add extendSelect option
1 parent cd8c3bc commit ad4b438

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ the valid configuration keys:
4040
- `pylsp.plugins.ruff.lineLength`: Set the line-length for length checks.
4141
- `pylsp.plugins.ruff.perFileIgnores`: File-specific error codes to be ignored.
4242
- `pylsp.plugins.ruff.select`: List of error codes to enable.
43+
- `pylsp.plugins.ruff.extendSelect`: Same as select, but append to existing error codes.
44+
45+
For more information on the configuration visit [Ruff's homepage](https://beta.ruff.rs/docs/configuration/).

pylsp_ruff/ruff_lint.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def pylsp_settings():
3333
"lineLength": None,
3434
"perFileIgnores": None,
3535
"select": None,
36+
"extendSelect": None,
3637
},
3738
"pyflakes": {"enabled": False},
3839
"flake8": {"enabled": False},
@@ -253,6 +254,7 @@ def load_config(workspace: Workspace, document: Document) -> dict:
253254
"line-length": None,
254255
"per-file-ignores": None,
255256
"select": None,
257+
"extend-select": None,
256258
}
257259

258260
else:
@@ -265,6 +267,7 @@ def load_config(workspace: Workspace, document: Document) -> dict:
265267
"line-length": _settings.get("lineLength", None),
266268
"per-file-ignores": _settings.get("perFileIgnores", None),
267269
"select": _settings.get("select", None),
270+
"extend-select": _settings.get("extendSelect", None),
268271
}
269272

270273
return settings

tests/test_ruff_lint.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,15 @@ def test_ruff_config_param(workspace):
7777
mock_instance = popen_mock.return_value
7878
mock_instance.communicate.return_value = [bytes(), bytes()]
7979
ruff_conf = "/tmp/pyproject.toml"
80-
workspace._config.update({"plugins": {"ruff": {"config": ruff_conf}}})
80+
workspace._config.update(
81+
{"plugins": {"ruff": {"config": ruff_conf, "extendSelect": ["D", "F"]}}}
82+
)
8183
_name, doc = temp_document(DOC, workspace)
8284
ruff_lint.pylsp_lint(workspace, doc)
8385
(call_args,) = popen_mock.call_args[0]
8486
assert "ruff" in call_args
8587
assert f"--config={ruff_conf}" in call_args
88+
assert "--extend-select=D,F" in call_args
8689

8790

8891
def test_ruff_executable_param(workspace):
@@ -122,6 +125,7 @@ def test_ruff_config(workspace):
122125
"blah/__init__.py",
123126
"file_2.py"
124127
]
128+
extend-select = ["D"]
125129
[tool.ruff.per-file-ignores]
126130
"test_something.py" = ["F401"]
127131
"""
@@ -172,8 +176,10 @@ def f():
172176
_list = []
173177
for diag in diags:
174178
_list.append(diag["code"])
175-
# Assert that ignore is working as intended
179+
# Assert that ignore and extend-select is working as intended
176180
assert "E402" in _list
181+
assert "D103" in _list
182+
assert "D104" in _list
177183
assert "F841" not in _list
178184

179185
# Excludes

0 commit comments

Comments
 (0)
0