2023-04-29 16:46:19 +00:00
|
|
|
{ lib
|
|
|
|
, pythonOlder
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
|
|
|
, ruff
|
2024-01-02 11:29:13 +00:00
|
|
|
, cattrs
|
2023-04-29 16:46:19 +00:00
|
|
|
, lsprotocol
|
|
|
|
, python-lsp-server
|
|
|
|
, tomli
|
2024-01-02 11:29:13 +00:00
|
|
|
, pytestCheckHook
|
2023-04-29 16:46:19 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "python-lsp-ruff";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "2.2.1";
|
2024-01-02 11:29:13 +00:00
|
|
|
pyproject = true;
|
|
|
|
disabled = pythonOlder "3.8";
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit version;
|
2024-05-15 15:35:15 +00:00
|
|
|
pname = "python_lsp_ruff";
|
|
|
|
hash = "sha256-C7OiJ7wTboq4xm6Rcz8mc9wV329/yeuZ1CZ9CZGzJ6U=";
|
2023-04-29 16:46:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# ruff binary is used directly, the ruff python package is not needed
|
|
|
|
sed -i '/"ruff>=/d' pyproject.toml
|
|
|
|
sed -i 's|sys.executable, "-m", "ruff"|"${ruff}/bin/ruff"|' pylsp_ruff/plugin.py
|
2024-01-02 11:29:13 +00:00
|
|
|
sed -i -e '/sys.executable/,+2c"${ruff}/bin/ruff",' -e 's|assert "ruff" in call_args|assert "${ruff}/bin/ruff" in call_args|' tests/test_ruff_lint.py
|
|
|
|
# Nix builds everything in /build/ but ruff somehow doesn't run on files in /build/ and outputs empty results.
|
|
|
|
sed -i -e "s|workspace.root_path|'/tmp/'|g" tests/*.py
|
2023-04-29 16:46:19 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
2024-01-02 11:29:13 +00:00
|
|
|
cattrs
|
2023-04-29 16:46:19 +00:00
|
|
|
lsprotocol
|
|
|
|
python-lsp-server
|
|
|
|
] ++ lib.optionals (pythonOlder "3.11") [
|
|
|
|
tomli
|
|
|
|
];
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
nativeCheckInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
];
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/python-lsp/python-lsp-ruff";
|
|
|
|
description = "Ruff linting plugin for pylsp";
|
|
|
|
changelog = "https://github.com/python-lsp/python-lsp-ruff/releases/tag/v${version}";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ linsui ];
|
|
|
|
};
|
|
|
|
}
|