From ca044a078c39f52d46a00b4b770df70914b06c35 Mon Sep 17 00:00:00 2001 From: DavHau Date: Fri, 21 Jul 2023 13:48:37 +0200 Subject: [PATCH] templates/python: fix type annotations --- templates/python-project/tests/conftest.py | 2 +- templates/python-project/tests/test_cli.py | 6 ++++-- templates/python-project/tests/test_detect_git_repo.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/templates/python-project/tests/conftest.py b/templates/python-project/tests/conftest.py index 55b2e9bdc..1c8106805 100644 --- a/templates/python-project/tests/conftest.py +++ b/templates/python-project/tests/conftest.py @@ -5,6 +5,6 @@ import pytest # returns a temporary directory with a fake git repo @pytest.fixture() -def git_repo_path(tmp_path): +def git_repo_path(tmp_path: str) -> str: subprocess.run(["mkdir", ".git"], cwd=tmp_path) return tmp_path diff --git a/templates/python-project/tests/test_cli.py b/templates/python-project/tests/test_cli.py index 5311f2bda..8855774af 100644 --- a/templates/python-project/tests/test_cli.py +++ b/templates/python-project/tests/test_cli.py @@ -1,15 +1,17 @@ import sys +import pytest + import my_tool -def test_no_args(capsys): +def test_no_args(capsys: pytest.CaptureFixture) -> None: my_tool.my_cli() captured = capsys.readouterr() assert captured.out.startswith("usage:") -def test_version(capsys, monkeypatch): +def test_version(capsys: pytest.CaptureFixture, monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr(sys, "argv", ["", "--version"]) my_tool.my_cli() captured = capsys.readouterr() diff --git a/templates/python-project/tests/test_detect_git_repo.py b/templates/python-project/tests/test_detect_git_repo.py index 529105c10..d54bf7e29 100644 --- a/templates/python-project/tests/test_detect_git_repo.py +++ b/templates/python-project/tests/test_detect_git_repo.py @@ -4,13 +4,13 @@ import my_lib # using the fixture from conftest.py -def test_is_git_repo(git_repo_path: str): +def test_is_git_repo(git_repo_path: str) -> None: result = my_lib.detect_git_repo(git_repo_path) assert result is True # using the fixture from conftest.py -def test_is_not_git_repo(): +def test_is_not_git_repo() -> None: with tempfile.TemporaryDirectory() as tempdir: result = my_lib.detect_git_repo(tempdir) assert result is False