1{ 2 lib, 3 pythonOlder, 4 buildPythonPackage, 5 fetchFromGitHub, 6 pytestCheckHook, 7 black, 8 python-lsp-server, 9 setuptools, 10 tomli, 11 fetchpatch, 12}: 13 14buildPythonPackage rec { 15 pname = "python-lsp-black"; 16 version = "2.0.0"; 17 pyproject = true; 18 disabled = pythonOlder "3.8"; 19 20 src = fetchFromGitHub { 21 owner = "python-lsp"; 22 repo = "python-lsp-black"; 23 rev = "refs/tags/v${version}"; 24 hash = "sha256-nV6mePSWzfPW2RwXg/mxgzfT9wD95mmTuPnPEro1kEY="; 25 }; 26 27 patches = 28 /** 29 includes a series of patches fixing tests not yet released as 2.0.1+ version 30 they are meant to keep up to date with black releases 31 */ 32 lib.optional (with lib; versionAtLeast black.version "24.2.0") (fetchpatch { 33 url = "https://github.com/python-lsp/python-lsp-black/commit/d43b41431379f9c9bb05fab158c4d97e6d515f8f.patch"; 34 hash = "sha256-38bYU27+xtA8Kq3appXTkNnkG5/XgrUJ2nQ5+yuSU2U="; 35 }) 36 ++ lib.optional (with lib; versionAtLeast black.version "24.3.0") (fetchpatch { 37 url = "https://github.com/python-lsp/python-lsp-black/commit/9298585a9d14d25920c33b188d79e820dc98d4a9.patch"; 38 hash = "sha256-4u0VIS7eidVEiKRW2wc8lJVkJwhzJD/M+uuqmTtiZ7E="; 39 }); 40 41 nativeBuildInputs = [ setuptools ]; 42 43 nativeCheckInputs = [ pytestCheckHook ]; 44 45 propagatedBuildInputs = [ 46 black 47 python-lsp-server 48 ] ++ lib.optionals (pythonOlder "3.11") [ tomli ]; 49 50 pythonImportsCheck = [ "pylsp_black" ]; 51 52 meta = with lib; { 53 homepage = "https://github.com/python-lsp/python-lsp-black"; 54 description = "Black plugin for the Python LSP Server"; 55 changelog = "https://github.com/python-lsp/python-lsp-black/blob/${src.rev}/CHANGELOG.md"; 56 license = licenses.mit; 57 maintainers = with maintainers; [ cpcloud ]; 58 }; 59}