From e806b5549d0c268e7e03f07ab88b3d371a0838d7 Mon Sep 17 00:00:00 2001 From: DavHau Date: Fri, 21 Jul 2023 13:34:35 +0200 Subject: [PATCH] clan-cli: enable mypy for tests --- pkgs/clan-cli/pyproject.toml | 3 --- pkgs/clan-cli/tests/test_clan_admin.py | 10 +++++++--- pkgs/clan-cli/tests/test_cli.py | 2 +- templates/python-project/pyproject.toml | 3 --- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pkgs/clan-cli/pyproject.toml b/pkgs/clan-cli/pyproject.toml index f763cdce6..fa2a29390 100644 --- a/pkgs/clan-cli/pyproject.toml +++ b/pkgs/clan-cli/pyproject.toml @@ -17,9 +17,6 @@ warn_redundant_casts = true disallow_untyped_calls = true disallow_untyped_defs = true no_implicit_optional = true -exclude = [ - "tests" -] [[tool.mypy.overrides]] module = "setuptools.*" diff --git a/pkgs/clan-cli/tests/test_clan_admin.py b/pkgs/clan-cli/tests/test_clan_admin.py index 555186c6d..db829c873 100644 --- a/pkgs/clan-cli/tests/test_clan_admin.py +++ b/pkgs/clan-cli/tests/test_clan_admin.py @@ -1,16 +1,20 @@ import argparse +from typing import Union + +import pytest_subprocess.fake_process +from pytest_subprocess import utils from clan_cli import admin -def test_make_parser(): +def test_make_parser() -> None: parser = argparse.ArgumentParser() admin.register_parser(parser) # using fp fixture from pytest-subprocess -def test_create(fp): - cmd = ["nix", "flake", "init", "-t", fp.any()] +def test_create(fp: pytest_subprocess.fake_process.FakeProcess) -> None: + cmd: list[Union[str, utils.Any]] = ["nix", "flake", "init", "-t", fp.any()] fp.register(cmd) args = argparse.Namespace(folder="./my-clan") admin.create(args) diff --git a/pkgs/clan-cli/tests/test_cli.py b/pkgs/clan-cli/tests/test_cli.py index 993e4b9fe..a02c03933 100644 --- a/pkgs/clan-cli/tests/test_cli.py +++ b/pkgs/clan-cli/tests/test_cli.py @@ -10,7 +10,7 @@ def test_no_args(capsys): assert captured.out.startswith("usage:") -def test_help(capsys, monkeypatch): +def test_help(capsys: pytest.CaptureFixture, monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr(sys, "argv", ["", "--help"]) with pytest.raises(SystemExit): clan_cli.main() diff --git a/templates/python-project/pyproject.toml b/templates/python-project/pyproject.toml index a3ee5c69e..22a6c9afb 100644 --- a/templates/python-project/pyproject.toml +++ b/templates/python-project/pyproject.toml @@ -20,9 +20,6 @@ warn_redundant_casts = true disallow_untyped_calls = true disallow_untyped_defs = true no_implicit_optional = true -exclude = [ - "tests" -] [[tool.mypy.overrides]] module = "setuptools.*"