1{ stdenv, lib
2, buildPythonPackage, fetchPypi, pythonOlder, setuptools_scm, pytestCheckHook
3, aiohttp
4, aiohttp-cors
5, appdirs
6, attrs
7, click
8, dataclasses
9, mypy-extensions
10, pathspec
11, regex
12, toml
13, typed-ast
14, typing-extensions }:
15
16buildPythonPackage rec {
17 pname = "black";
18 version = "20.8b1";
19
20 disabled = pythonOlder "3.6";
21
22 src = fetchPypi {
23 inherit pname version;
24 sha256 = "1spv6sldp3mcxr740dh3ywp25lly9s8qlvs946fin44rl1x5a0hw";
25 };
26
27 nativeBuildInputs = [ setuptools_scm ];
28
29 # Necessary for the tests to pass on Darwin with sandbox enabled.
30 # Black starts a local server and needs to bind a local address.
31 __darwinAllowLocalNetworking = true;
32
33 checkInputs = [ pytestCheckHook ];
34
35 preCheck = ''
36 export PATH="$PATH:$out/bin"
37 '';
38
39 disabledTests = [
40 # Don't know why these tests fails
41 "test_cache_multiple_files"
42 "test_failed_formatting_does_not_get_cached"
43 # requires network access
44 "test_gen_check_output"
45 "test_process_queue"
46 ] ++ lib.optionals stdenv.isDarwin [
47 # fails on darwin
48 "test_expression_diff"
49 ];
50
51 propagatedBuildInputs = [
52 aiohttp
53 aiohttp-cors
54 appdirs
55 attrs
56 click
57 mypy-extensions
58 pathspec
59 regex
60 toml
61 typed-ast
62 typing-extensions
63 ] ++ lib.optional (pythonOlder "3.7") dataclasses;
64
65 meta = with lib; {
66 description = "The uncompromising Python code formatter";
67 homepage = "https://github.com/psf/black";
68 changelog = "https://github.com/psf/black/blob/${version}/CHANGES.md";
69 license = licenses.mit;
70 maintainers = with maintainers; [ sveitser ];
71 };
72}