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.8.0";
23 pyproject = true;
24
25 disabled = pythonOlder "3.8";
26
27 src = fetchFromGitHub {
28 owner = "omnilib";
29 repo = "ufmt";
30 tag = "v${version}";
31 hash = "sha256-oEvvXUju7qne3pCwnrckplMs0kBJavB669qieXJZPKw=";
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 optional-dependencies = {
48 lsp = [ pygls ];
49 ruff = [ ruff-api ];
50 };
51
52 nativeCheckInputs = [
53 unittestCheckHook
54 ]
55 ++ lib.flatten (builtins.attrValues optional-dependencies);
56
57 pythonImportsCheck = [ "ufmt" ];
58
59 meta = with lib; {
60 description = "Safe, atomic formatting with black and usort";
61 homepage = "https://github.com/omnilib/ufmt";
62 changelog = "https://github.com/omnilib/ufmt/blob/${version}/CHANGELOG.md";
63 license = licenses.mit;
64 maintainers = with maintainers; [ fab ];
65 mainProgram = "ufmt";
66 };
67}