1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
{ lib
, stdenv
, buildPythonPackage
, fetchFromGitHub
, pythonAtLeast
, pythonOlder
# build-system
, setuptools
, types-psutil
, types-setuptools
# propagates
, mypy-extensions
, tomli
, typing-extensions
# optionals
, lxml
, psutil
# tests
, attrs
, filelock
, pytest-xdist
, pytest-forked
, pytestCheckHook
, py
, six
}:
buildPythonPackage rec {
pname = "mypy";
version = "1.8.0";
format = "pyproject";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "python";
repo = "mypy";
rev = "refs/tags/v${version}";
hash = "sha256-1YgAswqLadOVV5ZSi5ZXWYK3p114882IlSx0nKChGPs=";
};
nativeBuildInputs = [
mypy-extensions
setuptools
types-psutil
types-setuptools
typing-extensions
] ++ lib.optionals (pythonOlder "3.11") [
tomli
];
propagatedBuildInputs = [
mypy-extensions
typing-extensions
] ++ lib.optionals (pythonOlder "3.11") [
tomli
];
passthru.optional-dependencies = {
dmypy = [
psutil
];
reports = [
lxml
];
};
# Compile mypy with mypyc, which makes mypy about 4 times faster. The compiled
# version is also the default in the wheels on Pypi that include binaries.
# is64bit: unfortunately the build would exhaust all possible memory on i686-linux.
env.MYPY_USE_MYPYC = stdenv.buildPlatform.is64bit;
# when testing reduce optimisation level to reduce build time by 20%
env.MYPYC_OPT_LEVEL = 1;
pythonImportsCheck = [
"mypy"
"mypy.api"
"mypy.fastparse"
"mypy.types"
"mypyc"
"mypyc.analysis"
] ++ lib.optionals (!stdenv.hostPlatform.isi686) [
# ImportError: cannot import name 'map_instance_to_supertype' from partially initialized module 'mypy.maptype' (most likely due to a circular import)
"mypy.report"
];
checkInputs = [
attrs
filelock
pytest-xdist
pytest-forked
pytestCheckHook
py
setuptools
six
tomli
] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
disabledTests = lib.optionals (pythonAtLeast "3.12") [
# requires distutils
"test_c_unit_test"
];
disabledTestPaths = [
# fails to find tyoing_extensions
"mypy/test/testcmdline.py"
"mypy/test/testdaemon.py"
# fails to find setuptools
"mypyc/test/test_commandline.py"
# fails to find hatchling
"mypy/test/testpep561.py"
] ++ lib.optionals stdenv.hostPlatform.isi686 [
# https://github.com/python/mypy/issues/15221
"mypyc/test/test_run.py"
];
meta = with lib; {
description = "Optional static typing for Python";
homepage = "https://www.mypy-lang.org";
license = licenses.mit;
mainProgram = "mypy";
maintainers = with maintainers; [ lnl7 ];
};
}
|