Skip to content

Commit

Permalink
- F include py.typed
Browse files Browse the repository at this point in the history
  • Loading branch information
JayBazuzi committed Nov 4, 2024
1 parent 67ecfdc commit 72cdee5
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 2 deletions.
Empty file added approval_utilities/py.typed
Empty file.
Empty file added approvaltests/py.typed
Empty file.
4 changes: 3 additions & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-r requirements.prod.txt
-r requirements.test.txt
black
black
setuptools
mypy
3 changes: 2 additions & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
python -m pip install --upgrade pip
pip install tox
pip install pytest
tox -e py
tox -e py
tox -e test__py_typed_files_exist
59 changes: 59 additions & 0 deletions test__py_typed_files_exist.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 72cdee5

Please sign in to comment.