Skip to content

Commit

Permalink
Add typecheck (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
airtower-luna authored Oct 12, 2024
2 parents f2f67f0 + d2e6bcf commit 7221445
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nox_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 8 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# mypy: disallow-untyped-defs=False, check_untyped_defs=True
import nox


Expand All @@ -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."""
Expand Down
5 changes: 3 additions & 2 deletions test_nox_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 7221445

Please sign in to comment.