1{
2 lib,
3 black,
4 buildPythonPackage,
5 click,
6 fetchFromGitHub,
7 flit-core,
8 libcst,
9 moreorless,
10 pygls,
11 pythonOlder,
12 tomlkit,
13 trailrunner,
14 ruff-api,
15 typing-extensions,
16 unittestCheckHook,
17 usort,
18}:
19
20buildPythonPackage rec {
21 pname = "ufmt";
22 version = "2.7.0";
23 pyproject = true;
24
25 disabled = pythonOlder "3.";
26
27 src = fetchFromGitHub {
28 owner = "omnilib";
29 repo = "ufmt";
30 rev = "refs/tags/v${version}";
31 hash = "sha256-hIbzW7yDqk8siob+RhcnbOonkl+67sl/IGHimIeMM+Q=";
32 };
33
34 build-system = [ flit-core ];
35
36 dependencies = [
37 black
38 click
39 libcst
40 moreorless
41 tomlkit
42 trailrunner
43 typing-extensions
44 usort
45 ];
46
47 passthru.optional-dependencies = {
48 lsp = [ pygls ];
49 ruff = [ ruff-api ];
50 };
51
52 nativeCheckInputs = [
53 unittestCheckHook
54 ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
55
56 pythonImportsCheck = [ "ufmt" ];
57
58 meta = with lib; {
59 description = "Safe, atomic formatting with black and usort";
60 homepage = "https://github.com/omnilib/ufmt";
61 changelog = "https://github.com/omnilib/ufmt/blob/${version}/CHANGELOG.md";
62 license = licenses.mit;
63 maintainers = with maintainers; [ fab ];
64 mainProgram = "ufmt";
65 };
66}