Skip to content

Commit a10c6f1

Browse files
authored
Add setup.py to selfcheck (#18609)
mypy's setup.py is used as inspiration for other Setuptools-using projects that want to produce mypyc compiled binary wheels. Therefore it should also be typechecked and held to a higher standard.
1 parent d0e27fc commit a10c6f1

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Diff for: runtests.py

+9
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@
6565
"-p",
6666
"mypyc",
6767
],
68+
# Type check setup.py as well
69+
"self-packaging": [
70+
executable,
71+
"-m",
72+
"mypy",
73+
"--config-file",
74+
"mypy_self_check.ini",
75+
"setup.py",
76+
],
6877
# Lint
6978
"lint": ["pre-commit", "run", "--all-files"],
7079
# Fast test cases only (this is the bulk of the test suite)

Diff for: setup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def is_list_of_setuptools_extension(items: list[Any]) -> TypeGuard[list[Extensio
3131
return all(isinstance(item, Extension) for item in items)
3232

3333

34-
def find_package_data(base, globs, root="mypy"):
34+
def find_package_data(base: str, globs: list[str], root: str = "mypy") -> list[str]:
3535
"""Find all interesting data files, for setup(package_data=)
3636
3737
Arguments:
@@ -52,13 +52,13 @@ def find_package_data(base, globs, root="mypy"):
5252

5353

5454
class CustomPythonBuild(build_py):
55-
def pin_version(self):
55+
def pin_version(self) -> None:
5656
path = os.path.join(self.build_lib, "mypy")
5757
self.mkpath(path)
5858
with open(os.path.join(path, "version.py"), "w") as stream:
5959
stream.write(f'__version__ = "{version}"\n')
6060

61-
def run(self):
61+
def run(self) -> None:
6262
self.execute(self.pin_version, ())
6363
build_py.run(self)
6464

@@ -153,10 +153,10 @@ def run(self):
153153
# our Appveyor builds run out of memory sometimes.
154154
multi_file=sys.platform == "win32" or force_multifile,
155155
)
156-
assert is_list_of_setuptools_extension(ext_modules), "Expected mypycify to use setuptools"
157156

158157
else:
159158
ext_modules = []
160159

160+
assert is_list_of_setuptools_extension(ext_modules), "Expected mypycify to use setuptools"
161161

162162
setup(version=version, ext_modules=ext_modules, cmdclass=cmdclass)

0 commit comments

Comments
 (0)