Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typecheck #9

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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