Skip to content

Commit 7b48747

Browse files
committed
mypy: test_coverage.py, test_data.py
1 parent caa7e4b commit 7b48747

File tree

5 files changed

+194
-175
lines changed

5 files changed

+194
-175
lines changed

tests/coveragetest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from types import ModuleType
1919
from typing import (
2020
Any, Collection, Dict, Generator, Iterable, List, Mapping, Optional,
21-
Tuple, Union,
21+
Sequence, Tuple, Union,
2222
)
2323

2424
import coverage
@@ -135,8 +135,8 @@ def _check_arcs(
135135
def check_coverage(
136136
self,
137137
text: str,
138-
lines: Optional[Union[List[TLineNo], List[List[TLineNo]]]]=None,
139-
missing: Union[str, List[str]]="",
138+
lines: Optional[Union[Sequence[TLineNo], Sequence[List[TLineNo]]]]=None,
139+
missing: Union[str, Sequence[str]]="",
140140
report: str="",
141141
excludes: Optional[Iterable[str]]=None,
142142
partials: Iterable[str]=(),

tests/helpers.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from typing import (
1919
cast,
20-
Any, Callable, Generator, Iterable, List, Optional, Set, Tuple, Type, Union,
20+
Any, Callable, Generator, Iterable, List, Optional, Set, Tuple, Type, TypeVar, Union,
2121
)
2222

2323
import pytest
@@ -281,14 +281,20 @@ def change_dir(new_dir: str) -> Generator[None, None, None]:
281281
finally:
282282
os.chdir(old_dir)
283283

284+
T = TypeVar("T")
284285

285-
def assert_count_equal(a: Iterable[Union[int, str]], b: Iterable[Union[int, str]]) -> None:
286+
def assert_count_equal(
287+
a: Optional[Iterable[T]],
288+
b: Optional[Iterable[T]],
289+
) -> None:
286290
"""
287291
A pytest-friendly implementation of assertCountEqual.
288292
289293
Assert that `a` and `b` have the same elements, but maybe in different order.
290294
This only works for hashable elements.
291295
"""
296+
assert a is not None
297+
assert b is not None
292298
assert collections.Counter(list(a)) == collections.Counter(list(b))
293299

294300

0 commit comments

Comments
 (0)