diff --git a/approval_utilities/py.typed b/approval_utilities/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/approvaltests/py.typed b/approvaltests/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/requirements.dev.txt b/requirements.dev.txt index 7ca42ea..9cfe502 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -1,3 +1,5 @@ -r requirements.prod.txt -r requirements.test.txt -black \ No newline at end of file +black +setuptools +mypy diff --git a/run_tests.sh b/run_tests.sh index 311585e..49d92d8 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -2,4 +2,5 @@ set -euo pipefail python3 -m pip --disable-pip-version-check install tox -tox -e py \ No newline at end of file +tox -e py +tox -e test__py_typed_files_exist diff --git a/test__py_typed_files_exist.py b/test__py_typed_files_exist.py new file mode 100644 index 0000000..8eb26b4 --- /dev/null +++ b/test__py_typed_files_exist.py @@ -0,0 +1,59 @@ +import pathlib +import tempfile +import subprocess +import sys +import time +import typing + +from version import version_number + + +def main() -> None: + for package_name, setup_file in [ + ("approval_utilities", "setup.approval_utilities.py"), + ("approvaltests", "setup.py"), + ]: + build_number = str(int(time.time())) + _run_python_checked( + [ + setup_file, + "bdist_wheel", + "--build-number", + build_number, + ] + ) + _run_python_checked( + [ + "-m", + "pip", + "install", + "--force-reinstall", + # version_number starts with `v`; remove that character + f"dist/{package_name}-{version_number[1:]}-{build_number}-py3-none-any.whl", + ] + ) + + with tempfile.NamedTemporaryFile(suffix=".py") as _test_file: + test_file = pathlib.Path(_test_file.name) + test_file.write_text( + f"import {package_name}" + ) + + _run_python_checked( + ["-m", "mypy", test_file.name], + cwd=test_file.parent, + ) + + +def _run_python_checked( + args: typing.List[str], cwd: typing.Optional[pathlib.Path] = None +) -> None: + subprocess.run( + [sys.executable, *args], + check=True, + cwd=cwd, + ) + + +if __name__ == "__main__": + main() diff --git a/tox.ini b/tox.ini index 7aa41cd..a2cb4c6 100644 --- a/tox.ini +++ b/tox.ini @@ -25,3 +25,7 @@ commands = ; automatically install hook at .git/hooks ;{envdir}/bin/pre-commit install +[testenv:test__py_typed_files_exist] +deps = -rrequirements.txt +commands = + python test__py_typed_files_exist.py