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-01-25 14:12:00 +00:00
|
|
|
version = "2.0.2";
|
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;
|
|
|
|
pname = "python-lsp-ruff";
|
2024-01-25 14:12:00 +00:00
|
|
|
hash = "sha256-tKYhkRnXPZF1/9iK6ssNtoWa5y9gYVj9zFUOEFlXyOA=";
|
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 ];
|
|
|
|
};
|
|
|
|
}
|