Skip to content

Commit 8b94447

Browse files
authored
Merge pull request #349 from Avasam/re-enable-mypy-barebone
Re-enable mypy with only simple fixes
2 parents 1965578 + 3a5038b commit 8b94447

File tree

6 files changed

+50
-12
lines changed

6 files changed

+50
-12
lines changed

distutils/compilers/C/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ class Compiler:
120120
}
121121
language_order: ClassVar[list[str]] = ["c++", "objc", "c"]
122122

123-
include_dirs = []
123+
include_dirs: list[str] = []
124124
"""
125125
include dirs specific to this compiler class
126126
"""
127127

128-
library_dirs = []
128+
library_dirs: list[str] = []
129129
"""
130130
library dirs specific to this compiler class
131131
"""
@@ -148,14 +148,14 @@ def __init__(
148148
self.macros: list[_Macro] = []
149149

150150
# 'include_dirs': a list of directories to search for include files
151-
self.include_dirs: list[str] = []
151+
self.include_dirs = []
152152

153153
# 'libraries': a list of libraries to include in any link
154154
# (library names, not filenames: eg. "foo" not "libfoo.a")
155155
self.libraries: list[str] = []
156156

157157
# 'library_dirs': a list of directories to search for libraries
158-
self.library_dirs: list[str] = []
158+
self.library_dirs = []
159159

160160
# 'runtime_library_dirs': a list of directories to search for
161161
# shared libraries/objects at runtime

distutils/compilers/C/unix.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def _is_gcc(self):
323323
compiler = os.path.basename(shlex.split(cc_var)[0])
324324
return "gcc" in compiler or "g++" in compiler
325325

326-
def runtime_library_dir_option(self, dir: str) -> str | list[str]:
326+
def runtime_library_dir_option(self, dir: str) -> str | list[str]: # type: ignore[override] # Fixed in pypa/distutils#339
327327
# XXX Hackish, at the very least. See Python bug #445902:
328328
# https://bugs.python.org/issue445902
329329
# Linkers on different platforms need different options to

distutils/dist.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def __init__(self, attrs: MutableMapping[str, Any] | None = None) -> None: # no
183183
# can 1) quickly figure out which class to instantiate when
184184
# we need to create a new command object, and 2) have a way
185185
# for the setup script to override command classes
186-
self.cmdclass = {}
186+
self.cmdclass: dict[str, type[Command]] = {}
187187

188188
# 'command_packages' is a list of packages in which commands
189189
# are searched for. The factory for command 'foo' is expected
@@ -1168,6 +1168,7 @@ def _read_field(name: str) -> str | None:
11681168
value = msg[name]
11691169
if value and value != "UNKNOWN":
11701170
return value
1171+
return None
11711172

11721173
def _read_list(name):
11731174
values = msg.get_all(name, None)

distutils/tests/test_build_ext.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_build_ext(self, copy_so):
146146

147147
@staticmethod
148148
def _test_xx(copy_so):
149-
import xx
149+
import xx # type: ignore[import-not-found] # Module generated for tests
150150

151151
for attr in ('error', 'foo', 'new', 'roj'):
152152
assert hasattr(xx, attr)

mypy.ini

+41
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,44 @@ explicit_package_bases = True
1313
disable_error_code =
1414
# Disable due to many false positives
1515
overload-overlap,
16+
17+
# local
18+
19+
# TODO: Resolve and re-enable these gradually
20+
operator,
21+
attr-defined,
22+
arg-type,
23+
assignment,
24+
call-overload,
25+
return-value,
26+
index,
27+
type-var,
28+
func-returns-value,
29+
union-attr,
30+
str-bytes-safe,
31+
misc,
32+
has-type,
33+
34+
# Is only imported in a test and doesn't seem relevant.
35+
# TODO: Should we add types-pygments or remove from the test?
36+
[mypy-pygments.*]
37+
ignore_missing_imports = True
38+
39+
# stdlib's test module is not typed on typeshed
40+
[mypy-test.*]
41+
ignore_missing_imports = True
42+
43+
# https://github.com/jaraco/jaraco.envs/issues/7
44+
# https://github.com/jaraco/jaraco.envs/pull/8
45+
[mypy-jaraco.envs.*]
46+
ignore_missing_imports = True
47+
48+
# https://github.com/jaraco/jaraco.path/issues/2
49+
# https://github.com/jaraco/jaraco.path/pull/7
50+
[mypy-jaraco.path.*]
51+
ignore_missing_imports = True
52+
53+
# https://github.com/jaraco/jaraco.text/issues/17
54+
# https://github.com/jaraco/jaraco.text/pull/23
55+
[mypy-jaraco.text.*]
56+
ignore_missing_imports = True

pyproject.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,8 @@ type = [
7676
"pytest-mypy",
7777

7878
# local
79+
"types-docutils",
7980
]
8081

8182

8283
[tool.setuptools_scm]
83-
84-
85-
[tool.pytest-enabler.mypy]
86-
# Disabled due to jaraco/skeleton#143
87-
# Disabled as distutils isn't ready yet

0 commit comments

Comments
 (0)