1{
2 lib,
3 astroid,
4 buildPythonPackage,
5 deal-solver,
6 docstring-parser,
7 fetchFromGitHub,
8 flit-core,
9 hypothesis,
10 marshmallow,
11 pygments,
12 pytestCheckHook,
13 pythonOlder,
14 sphinx,
15 typeguard,
16 urllib3,
17 vaa,
18}:
19
20buildPythonPackage rec {
21 pname = "deal";
22 version = "4.24.4";
23 pyproject = true;
24
25 disabled = pythonOlder "3.7";
26
27 src = fetchFromGitHub {
28 owner = "life4";
29 repo = "deal";
30 rev = "refs/tags/${version}";
31 hash = "sha256-4orpoYfPGSvquhg9w63uUe8QbBa2RUpxaEJ9uy28+fU=";
32 };
33
34 postPatch = ''
35 # don't do coverage
36 substituteInPlace pyproject.toml \
37 --replace-fail '"--cov-fail-under=100",' "" \
38 --replace-fail '"--cov=deal",' "" \
39 --replace-fail '"--cov-report=html",' "" \
40 --replace-fail '"--cov-report=term-missing:skip-covered",' ""
41 '';
42
43 build-system = [ flit-core ];
44
45 dependencies = [
46 astroid
47 deal-solver
48 pygments
49 typeguard
50 ];
51
52 nativeCheckInputs = [
53 docstring-parser
54 hypothesis
55 marshmallow
56 pytestCheckHook
57 sphinx
58 urllib3
59 vaa
60 ];
61
62 disabledTests = [
63 # Tests need internet access
64 "test_smoke_has"
65 "test_pure_offline"
66 "test_raises_doesnt_override_another_contract"
67 "test_raises_doesnt_override_another_contract_async"
68 "test_raises_generator"
69 # AttributeError: module 'vaa' has no attribute 'Error'
70 "test_source_vaa_scheme"
71 "test_vaa_scheme_and_custom_exception"
72 "test_scheme_string_validation_args_correct"
73 "test_method_chain_decorator_with_scheme_is_fulfilled"
74 "test_scheme_contract_is_satisfied_when_setting_arg"
75 "test_scheme_contract_is_satisfied_within_chain"
76 "test_scheme_errors_rewrite_message"
77 # assert errors
78 "test_doctest"
79 "test_no_violations"
80 "test_source_get_lambda_multiline_splitted_dec"
81 ];
82
83 disabledTestPaths = [
84 # Test needs internet access
85 "tests/test_runtime/test_offline.py"
86 # depends on typeguard <4.0.0 for tests, but >=4.0.0 seems fine for runtime
87 # https://github.com/life4/deal/blob/9be70fa1c5a0635880619b2cea83a9f6631eb236/pyproject.toml#L40
88 "tests/test_testing.py"
89 ];
90
91 pythonImportsCheck = [ "deal" ];
92
93 meta = with lib; {
94 description = "Library for design by contract (DbC) and checking values, exceptions, and side-effects";
95 longDescription = ''
96 In a nutshell, deal empowers you to write bug-free code.
97 By adding a few decorators to your code, you get for free tests, static analysis, formal verification,
98 and much more.
99 '';
100 homepage = "https://github.com/life4/deal";
101 changelog = "https://github.com/life4/deal/releases/tag/${version}";
102 license = licenses.mit;
103 maintainers = with maintainers; [ gador ];
104 };
105}