diff --git a/nox_report.py b/nox_report.py index 7661d5b..141bbe4 100755 --- a/nox_report.py +++ b/nox_report.py @@ -2,7 +2,7 @@ import json -def parse_report(report_file, title): +def parse_report(report_file: str, title: str) -> None: with open(report_file, 'r') as fh: report = json.load(fh) diff --git a/noxfile.py b/noxfile.py index 2ec9079..1936168 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,3 +1,4 @@ +# mypy: disallow-untyped-defs=False, check_untyped_defs=True import nox @@ -8,6 +9,13 @@ def lint(session): session.run('flake8', '--statistics', '.') +@nox.session +def typecheck(session): + """Typecheck using MyPy.""" + session.install('mypy', 'pytest', 'nox') + session.run('mypy', '--strict', '.') + + @nox.session(python=['3.11', '3.12', '3.13']) def test(session): """Run tests.""" diff --git a/test_nox_report.py b/test_nox_report.py index 9ab4a94..731bc9c 100644 --- a/test_nox_report.py +++ b/test_nox_report.py @@ -5,11 +5,12 @@ @pytest.fixture -def sample_report(): +def sample_report() -> Path: return Path(__file__).parent / 'sample_report.json' -def test_output(capsys, sample_report): +def test_output( + capsys: pytest.CaptureFixture[str], sample_report: Path) -> None: nox_report.parse_report(str(sample_report), 'Nox test') out, _ = capsys.readouterr() assert out == textwrap.dedent(