2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
2024-07-27 06:49:29 +00:00
|
|
|
pythonOlder,
|
|
|
|
fetchFromGitHub,
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
ruff,
|
2024-07-27 06:49:29 +00:00
|
|
|
|
|
|
|
# dependencies
|
2024-06-05 15:53:02 +00:00
|
|
|
cattrs,
|
|
|
|
lsprotocol,
|
|
|
|
python-lsp-server,
|
|
|
|
tomli,
|
2024-07-27 06:49:29 +00:00
|
|
|
|
|
|
|
# checks
|
2024-06-05 15:53:02 +00:00
|
|
|
pytestCheckHook,
|
2023-04-29 16:46:19 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "python-lsp-ruff";
|
2024-07-27 06:49:29 +00:00
|
|
|
version = "2.2.2";
|
2024-01-02 11:29:13 +00:00
|
|
|
pyproject = true;
|
|
|
|
disabled = pythonOlder "3.8";
|
2023-04-29 16:46:19 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "python-lsp";
|
|
|
|
repo = "python-lsp-ruff";
|
|
|
|
rev = "refs/tags/v${version}";
|
|
|
|
hash = "sha256-czGA/gl7uoWG9UqYUaY9zER79IKfv7ClqgimgyNCAa4=";
|
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
|
|
|
'';
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
dependencies = [
|
2024-01-02 11:29:13 +00:00
|
|
|
cattrs
|
2023-04-29 16:46:19 +00:00
|
|
|
lsprotocol
|
|
|
|
python-lsp-server
|
2024-06-05 15:53:02 +00:00
|
|
|
] ++ lib.optionals (pythonOlder "3.11") [ tomli ];
|
2023-04-29 16:46:19 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeCheckInputs = [ pytestCheckHook ];
|
2023-04-29 16:46:19 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
meta = {
|
2023-04-29 16:46:19 +00:00
|
|
|
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}";
|
2024-07-27 06:49:29 +00:00
|
|
|
license = lib.licenses.mit;
|
|
|
|
maintainers = with lib.maintainers; [ linsui ];
|
2023-04-29 16:46:19 +00:00
|
|
|
};
|
|
|
|
}
|