omdev 0.0.0.dev322__py3-none-any.whl → 0.0.0.dev323__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omdev/mypy/debug.py +41 -4
- omdev/mypy/report.py +62 -0
- {omdev-0.0.0.dev322.dist-info → omdev-0.0.0.dev323.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev322.dist-info → omdev-0.0.0.dev323.dist-info}/RECORD +8 -7
- {omdev-0.0.0.dev322.dist-info → omdev-0.0.0.dev323.dist-info}/WHEEL +0 -0
- {omdev-0.0.0.dev322.dist-info → omdev-0.0.0.dev323.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev322.dist-info → omdev-0.0.0.dev323.dist-info}/licenses/LICENSE +0 -0
- {omdev-0.0.0.dev322.dist-info → omdev-0.0.0.dev323.dist-info}/top_level.txt +0 -0
omdev/mypy/debug.py
CHANGED
@@ -3,6 +3,9 @@ import re
|
|
3
3
|
import sys
|
4
4
|
|
5
5
|
|
6
|
+
##
|
7
|
+
|
8
|
+
|
6
9
|
def _is_instance_or_subclass(obj, cls):
|
7
10
|
return (isinstance(obj, type) and issubclass(obj, cls)) or isinstance(obj, cls)
|
8
11
|
|
@@ -11,44 +14,57 @@ class MypyDebugPathFinder(importlib.machinery.PathFinder):
|
|
11
14
|
@classmethod
|
12
15
|
def _get_spec(cls, fullname, path, target=None): # noqa
|
13
16
|
namespace_path = []
|
17
|
+
|
14
18
|
for entry in path:
|
15
19
|
if not isinstance(entry, (str, bytes)):
|
16
20
|
continue
|
21
|
+
|
17
22
|
finder = cls._path_importer_cache(entry) # type: ignore # noqa
|
18
23
|
if finder is not None:
|
19
24
|
if isinstance(finder, importlib.machinery.FileFinder):
|
20
25
|
finder = importlib.machinery.FileFinder(
|
21
26
|
finder.path,
|
22
27
|
*[
|
23
|
-
(i, [s])
|
28
|
+
(i, [s])
|
29
|
+
for s, i in finder._loaders # type: ignore # noqa
|
24
30
|
if not _is_instance_or_subclass(i, importlib.machinery.ExtensionFileLoader)
|
25
31
|
],
|
26
32
|
)
|
33
|
+
|
27
34
|
if hasattr(finder, 'find_spec'):
|
28
35
|
spec = finder.find_spec(fullname, target)
|
29
36
|
else:
|
30
37
|
spec = cls._legacy_get_spec(fullname, finder) # type: ignore # noqa
|
38
|
+
|
31
39
|
if spec is None:
|
32
40
|
continue
|
41
|
+
|
33
42
|
if spec.loader is not None:
|
34
43
|
return spec
|
44
|
+
|
35
45
|
portions = spec.submodule_search_locations
|
36
46
|
if portions is None:
|
37
47
|
raise ImportError('spec missing loader')
|
48
|
+
|
38
49
|
namespace_path.extend(portions)
|
50
|
+
|
39
51
|
return None
|
40
52
|
|
41
53
|
@classmethod
|
42
54
|
def find_spec(cls, fullname, path=None, target=None): # noqa
|
43
55
|
if not fullname.startswith('mypy.') and fullname != 'mypy':
|
44
56
|
return None
|
57
|
+
|
45
58
|
if path is None:
|
46
59
|
path = sys.path
|
60
|
+
|
47
61
|
spec = cls._get_spec(fullname, path, target)
|
48
62
|
if spec is None:
|
49
63
|
return None
|
64
|
+
|
50
65
|
elif spec.loader is None:
|
51
66
|
namespace_path = spec.submodule_search_locations
|
67
|
+
|
52
68
|
if namespace_path:
|
53
69
|
spec.origin = None
|
54
70
|
spec.submodule_search_locations = importlib.machinery._NamespacePath( # type: ignore # noqa
|
@@ -57,29 +73,50 @@ class MypyDebugPathFinder(importlib.machinery.PathFinder):
|
|
57
73
|
cls._get_spec,
|
58
74
|
)
|
59
75
|
return spec
|
76
|
+
|
60
77
|
else:
|
61
78
|
return None
|
79
|
+
|
62
80
|
else:
|
63
81
|
return spec
|
64
82
|
|
65
83
|
|
66
|
-
def
|
84
|
+
def install_debug_path_finder() -> None:
|
67
85
|
for i, e in enumerate(sys.meta_path): # noqa
|
68
86
|
if _is_instance_or_subclass(e, importlib.machinery.PathFinder):
|
69
87
|
break
|
88
|
+
|
70
89
|
sys.meta_path.insert(i, MypyDebugPathFinder) # noqa
|
71
90
|
sys.path_importer_cache.clear()
|
72
91
|
importlib.invalidate_caches()
|
73
92
|
|
93
|
+
|
94
|
+
##
|
95
|
+
|
96
|
+
|
97
|
+
def run_mypy_main(
|
98
|
+
*,
|
99
|
+
show_traceback: bool = False,
|
100
|
+
) -> None:
|
74
101
|
from mypy.__main__ import console_entry # noqa
|
75
102
|
|
76
103
|
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
77
104
|
|
78
|
-
if
|
79
|
-
sys.argv
|
105
|
+
if show_traceback:
|
106
|
+
if not any(k in sys.argv[1:] for k in ['--show-traceback', '--tb']):
|
107
|
+
sys.argv.insert(1, '--show-traceback')
|
80
108
|
|
81
109
|
console_entry()
|
82
110
|
|
83
111
|
|
112
|
+
##
|
113
|
+
|
114
|
+
|
115
|
+
def _main() -> None:
|
116
|
+
install_debug_path_finder()
|
117
|
+
|
118
|
+
run_mypy_main(show_traceback=True)
|
119
|
+
|
120
|
+
|
84
121
|
if __name__ == '__main__':
|
85
122
|
_main()
|
omdev/mypy/report.py
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
import collections
|
2
|
+
import typing as ta
|
3
|
+
|
4
|
+
from .debug import install_debug_path_finder
|
5
|
+
from .debug import run_mypy_main
|
6
|
+
|
7
|
+
|
8
|
+
if ta.TYPE_CHECKING:
|
9
|
+
import mypy.build
|
10
|
+
import mypy.errors
|
11
|
+
|
12
|
+
|
13
|
+
##
|
14
|
+
|
15
|
+
|
16
|
+
def _report_build_result(
|
17
|
+
result: 'mypy.build.BuildResult',
|
18
|
+
) -> None:
|
19
|
+
errors: ta.Sequence[mypy.errors.ErrorInfo] = [
|
20
|
+
e
|
21
|
+
for es in result.manager.errors.error_info_map.values()
|
22
|
+
for e in es
|
23
|
+
]
|
24
|
+
if errors:
|
25
|
+
count_by_code = collections.Counter(
|
26
|
+
e.code.code
|
27
|
+
for e in errors
|
28
|
+
if e.code is not None
|
29
|
+
)
|
30
|
+
|
31
|
+
print()
|
32
|
+
max_code_len = max(map(len, count_by_code))
|
33
|
+
for code, count in sorted(count_by_code.items(), key=lambda kv: -kv[1]):
|
34
|
+
print(f'{code.rjust(max_code_len)} : {count}')
|
35
|
+
|
36
|
+
|
37
|
+
##
|
38
|
+
|
39
|
+
|
40
|
+
def _main() -> None:
|
41
|
+
install_debug_path_finder()
|
42
|
+
|
43
|
+
##
|
44
|
+
|
45
|
+
import mypy.main
|
46
|
+
|
47
|
+
old_run_build = mypy.main.run_build
|
48
|
+
|
49
|
+
def new_run_build(*args, **kwargs):
|
50
|
+
ret = old_run_build(*args, **kwargs)
|
51
|
+
_report_build_result(ta.cast('mypy.build.BuildResult', ret[0]))
|
52
|
+
return ret
|
53
|
+
|
54
|
+
mypy.main.run_build = new_run_build
|
55
|
+
|
56
|
+
##
|
57
|
+
|
58
|
+
run_mypy_main()
|
59
|
+
|
60
|
+
|
61
|
+
if __name__ == '__main__':
|
62
|
+
_main()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: omdev
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev323
|
4
4
|
Summary: omdev
|
5
5
|
Author: wrmsr
|
6
6
|
License: BSD-3-Clause
|
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Operating System :: POSIX
|
13
13
|
Requires-Python: >=3.12
|
14
14
|
License-File: LICENSE
|
15
|
-
Requires-Dist: omlish==0.0.0.
|
15
|
+
Requires-Dist: omlish==0.0.0.dev323
|
16
16
|
Provides-Extra: all
|
17
17
|
Requires-Dist: black~=25.1; extra == "all"
|
18
18
|
Requires-Dist: pycparser~=2.22; extra == "all"
|
@@ -168,7 +168,8 @@ omdev/manifests/build.py,sha256=1Ah6NhNylAT-bIfDlKDOVlfitxe9UNYPudOwxO0s1aY,1002
|
|
168
168
|
omdev/manifests/dumping.py,sha256=mYXO58oXWQdTIn7A9XTnGv2-3LRPvO_uQmqkwPn9cMw,3470
|
169
169
|
omdev/manifests/main.py,sha256=7zRlyE0BDPqITEbChlTBRGulAvG1nUZPHXrerNExriE,2126
|
170
170
|
omdev/mypy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
171
|
-
omdev/mypy/debug.py,sha256=
|
171
|
+
omdev/mypy/debug.py,sha256=VskRcr9trNhyPG2ErZZ7IX_v1DLKTLBOjp34o-fEWaM,3294
|
172
|
+
omdev/mypy/report.py,sha256=iILB5a1oy_JB4LEKOprJOv0jne2V7uPnftL7afyp_l8,1207
|
172
173
|
omdev/oci/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
173
174
|
omdev/oci/building.py,sha256=g1TY-a2eHgEamYv0mt1L6rOevwOgdp_cW1xdVdjDzTw,5695
|
174
175
|
omdev/oci/compression.py,sha256=5hs7u0hImsm22GcQBHGYnP6g9dr-lBZ3E_PzdNVD4WY,134
|
@@ -294,9 +295,9 @@ omdev/tools/json/rendering.py,sha256=3HhdlKSetS6iK1tjF2aILzsl8Mb3D8wW92vYwGpRdVA
|
|
294
295
|
omdev/tools/pawk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
295
296
|
omdev/tools/pawk/__main__.py,sha256=VCqeRVnqT1RPEoIrqHFSu4PXVMg4YEgF4qCQm90-eRI,66
|
296
297
|
omdev/tools/pawk/pawk.py,sha256=zsEkfQX0jF5bn712uqPAyBSdJt2dno1LH2oeSMNfXQI,11424
|
297
|
-
omdev-0.0.0.
|
298
|
-
omdev-0.0.0.
|
299
|
-
omdev-0.0.0.
|
300
|
-
omdev-0.0.0.
|
301
|
-
omdev-0.0.0.
|
302
|
-
omdev-0.0.0.
|
298
|
+
omdev-0.0.0.dev323.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
299
|
+
omdev-0.0.0.dev323.dist-info/METADATA,sha256=hjlKA2IkJS_PYyADH_w2QYrAPiitaD8ichH_6_b_HMY,1674
|
300
|
+
omdev-0.0.0.dev323.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
301
|
+
omdev-0.0.0.dev323.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
|
302
|
+
omdev-0.0.0.dev323.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
|
303
|
+
omdev-0.0.0.dev323.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|