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