Skip to content

Commit e205e70

Browse files
committed
fix: resolve type checking issues and exclude mutants from pyright
- Add ValidVerbosity import and type casting in tests - Configure pyright to exclude mutants/ and .mutmut-cache/ directories - Add proper type annotations with cast() for hypothesis tests - Fix intentionally invalid test case with type: ignore comment - All tests pass (5/5) and type checking is clean
1 parent 48a093e commit e205e70

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ echo "Generated: $(date)" >> docs/mutation/summary.txt
173173
mut-clean = "rm -rf .mutmut-cache mutants/"
174174
static-check = "pyright"
175175

176+
[tool.pyright]
177+
exclude = ["mutants/**", ".mutmut-cache/**"]
178+
include = ["python_package_template", "tests", "main.py", "setup_project.py"]
179+
176180
[tool.mutmut]
177181
paths_to_mutate = ["python_package_template/"]
178182
pytest_add_cli_args_test_selection = ["tests/"]
@@ -182,6 +186,7 @@ do_not_mutate = [
182186
"**/*_test.py",
183187
"**/test_*.py",
184188
"**/conftest.py",
189+
"**/__init__.py"
185190
]
186191

187192
[dependency-groups]

tests/version_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import logging
44
import tomllib
55
from pathlib import Path
6+
from typing import cast
67
from unittest.mock import patch
78

89
import pytest
910
from hypothesis import assume, example, given
1011
from hypothesis import strategies as st
1112

12-
from main import main
13+
from main import ValidVerbosity, main
1314
from python_package_template import python_module_template as m
1415

1516

@@ -90,8 +91,8 @@ def mock_basic_config(**kwargs):
9091
with patch(
9192
"main.logging.basicConfig", side_effect=mock_basic_config
9293
) as mock_basic_config:
93-
# Call main() directly with the verbosity level
94-
main(verbosity)
94+
# Call main() directly with the verbosity level (cast to satisfy type checker)
95+
main(cast(ValidVerbosity, verbosity))
9596

9697
# Verify that logging.basicConfig was called with the correct level
9798
mock_basic_config.assert_called_once()
@@ -126,8 +127,9 @@ def test_main_with_invalid_verbosity_should_raise_value_error() -> None:
126127
Then: Should raise ValueError with helpful message
127128
"""
128129
# Test that calling main() with invalid verbosity raises ValueError
130+
# Use cast to bypass type checking for this intentionally invalid test
129131
with pytest.raises(ValueError, match=r"Invalid verbosity level") as exc_info:
130-
main("INVALID_LEVEL")
132+
main(cast(ValidVerbosity, "INVALID_LEVEL")) # type: ignore[arg-type]
131133

132134
# Verify the error message contains expected details
133135
error_message = str(exc_info.value)

0 commit comments

Comments
 (0)