Skip to content

Commit 92e54ad

Browse files
committed
maint: add mypy to project
Adds all type annotations to satisfy mypy. There should be 0 functional changes.
1 parent 88520be commit 92e54ad

9 files changed

Lines changed: 300 additions & 226 deletions

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,17 @@ repos:
2020
- id: ruff
2121
args: [--fix, --exit-non-zero-on-fix]
2222
- id: ruff-format
23+
- repo: https://github.com/pre-commit/mirrors-mypy
24+
rev: v1.19.1
25+
hooks:
26+
- id: mypy
27+
args: [--config-file=mypy.ini]
28+
exclude: (tests/|docs/)
29+
additional_dependencies:
30+
- click>=8.0.0
31+
- coverage>=7.3.0
32+
- libcst>=1.8.5
33+
- pytest>=6.2.5
34+
- setproctitle>=1.1.0
35+
- textual>=1.0.0
36+
- types-toml>=0.10.2

mypy.ini

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[mypy]
2+
mypy_path = src:types
3+
strict = True
4+
check_untyped_defs = True
5+
explicit_package_bases = True
6+
warn_redundant_casts = True
7+
8+
[mypy-hammett]
9+
ignore_missing_imports = True
10+
11+
[mypy-e2e_projects.*]
12+
ignore_errors = True

src/mutmut/__init__.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1+
from __future__ import annotations
2+
13
import importlib.metadata
24
from collections import defaultdict
5+
from typing import TYPE_CHECKING
6+
7+
if TYPE_CHECKING:
8+
from mutmut.__main__ import Config
39

410
__version__ = importlib.metadata.version("mutmut")
511

612

7-
duration_by_test = defaultdict(float)
8-
stats_time = None
9-
config = None
13+
duration_by_test: defaultdict[str, float] = defaultdict(float)
14+
stats_time: float | None = None
15+
config: Config | None = None
1016

11-
_stats = set()
12-
tests_by_mangled_function_name = defaultdict(set)
13-
_covered_lines = None
17+
_stats: set[str] = set()
18+
tests_by_mangled_function_name: defaultdict[str, set[str]] = defaultdict(set)
19+
_covered_lines: dict[str, set[int]] | None = None
1420

1521

16-
def _reset_globals():
22+
def _reset_globals() -> None:
1723
global duration_by_test, stats_time, config, _stats, tests_by_mangled_function_name
1824
global _covered_lines
1925

0 commit comments

Comments
 (0)