Commit 43326297 authored by Gaetan Lepage's avatar Gaetan Lepage
Browse files

python311Packages.python-lsp-ruff: 1.6.0 -> 2.0.0

parent 8cfef698
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -3,37 +3,45 @@
, buildPythonPackage
, fetchPypi
, ruff
, cattrs
, lsprotocol
, python-lsp-server
, tomli
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "python-lsp-ruff";
  version = "1.6.0";
  format = "pyproject";
  disabled = pythonOlder "3.7";
  version = "2.0.0";
  pyproject = true;
  disabled = pythonOlder "3.8";

  src = fetchPypi {
    inherit version;
    pname = "python-lsp-ruff";
    sha256 = "sha256-vf3ZNZyen1W29qk4ST1sus5VTcys9F3067NlUr406bg=";
    sha256 = "sha256-lCTBFKTb1djrRQcX4Eg/G2Fs+VrqTvJ/XVnUPVM/5nE=";
  };

  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
    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
  '';

  propagatedBuildInputs = [
    cattrs
    lsprotocol
    python-lsp-server
  ] ++ lib.optionals (pythonOlder "3.11") [
    tomli
  ];

  doCheck = true;
  nativeCheckInputs = [
    pytestCheckHook
  ];

  meta = with lib; {
    homepage = "https://github.com/python-lsp/python-lsp-ruff";