Skip to content

Commit 35d58fc

Browse files
committed
Add setup.py to selfcheck.
Enhance the setup.py types. mypy's setup.py is used as inspiration for other setuptools using Python projects that want to produce mypyc compiled binary wheels. Therefore it should also be typechecked and held to a higher standard.
1 parent 88d6890 commit 35d58fc

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

runtests.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,10 @@
5656
# Self type check
5757
"self": [
5858
executable,
59-
"-m",
60-
"mypy",
61-
"--config-file",
62-
"mypy_self_check.ini",
63-
"-p",
64-
"mypy",
65-
"-p",
66-
"mypyc",
59+
"-c",
60+
"from mypy.main import main as mypy; "
61+
"mypy(args=['--config-file', 'mypy_self_check.ini', '-p', 'mypy', '-p', 'mypyc']); "
62+
"mypy(args=['--config-file', 'mypy_self_check.ini', 'setup.py'])"
6763
],
6864
# Lint
6965
"lint": ["pre-commit", "run", "--all-files"],

setup.py

Lines changed: 4 additions & 4 deletions
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)