Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ the valid configuration keys:
- `pylsp.plugins.ruff.lineLength`: Set the line-length for length checks.
- `pylsp.plugins.ruff.perFileIgnores`: File-specific error codes to be ignored.
- `pylsp.plugins.ruff.select`: List of error codes to enable.
- `pylsp.plugins.ruff.extendSelect`: Same as select, but append to existing error codes.

For more information on the configuration visit [Ruff's homepage](https://beta.ruff.rs/docs/configuration/).
3 changes: 3 additions & 0 deletions pylsp_ruff/ruff_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def pylsp_settings():
"lineLength": None,
"perFileIgnores": None,
"select": None,
"extendSelect": None,
},
"pyflakes": {"enabled": False},
"flake8": {"enabled": False},
Expand Down Expand Up @@ -253,6 +254,7 @@ def load_config(workspace: Workspace, document: Document) -> dict:
"line-length": None,
"per-file-ignores": None,
"select": None,
"extend-select": None,
}

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

return settings
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "python-lsp-ruff"
authors = [
{name = "Julian Hossbach", email = "julian.hossbach@gmx.de"}
]
version = "1.0.5"
version = "1.1.0"
description = "Ruff linting plugin for pylsp"
readme = "README.md"
requires-python = ">=3.7"
Expand Down
10 changes: 8 additions & 2 deletions tests/test_ruff_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ def test_ruff_config_param(workspace):
mock_instance = popen_mock.return_value
mock_instance.communicate.return_value = [bytes(), bytes()]
ruff_conf = "/tmp/pyproject.toml"
workspace._config.update({"plugins": {"ruff": {"config": ruff_conf}}})
workspace._config.update(
{"plugins": {"ruff": {"config": ruff_conf, "extendSelect": ["D", "F"]}}}
)
_name, doc = temp_document(DOC, workspace)
ruff_lint.pylsp_lint(workspace, doc)
(call_args,) = popen_mock.call_args[0]
assert "ruff" in call_args
assert f"--config={ruff_conf}" in call_args
assert "--extend-select=D,F" in call_args


def test_ruff_executable_param(workspace):
Expand Down Expand Up @@ -122,6 +125,7 @@ def test_ruff_config(workspace):
"blah/__init__.py",
"file_2.py"
]
extend-select = ["D"]
[tool.ruff.per-file-ignores]
"test_something.py" = ["F401"]
"""
Expand Down Expand Up @@ -172,8 +176,10 @@ def f():
_list = []
for diag in diags:
_list.append(diag["code"])
# Assert that ignore is working as intended
# Assert that ignore and extend-select is working as intended
assert "E402" in _list
assert "D103" in _list
assert "D104" in _list
assert "F841" not in _list

# Excludes
Expand Down