Skip to content

Commit 9e44b6e

Browse files
committed
style: tighten some mypy pragmas
1 parent d01009b commit 9e44b6e

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

coverage/config.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def set_option(self, option_name: str, value: Union[TConfigValueIn, TConfigSecti
465465
"""
466466
# Special-cased options.
467467
if option_name == "paths":
468-
self.paths = value # type: ignore
468+
self.paths = value # type: ignore[assignment]
469469
return
470470

471471
# Check all the hard-coded options.
@@ -478,7 +478,7 @@ def set_option(self, option_name: str, value: Union[TConfigValueIn, TConfigSecti
478478
# See if it's a plugin option.
479479
plugin_name, _, key = option_name.partition(":")
480480
if key and plugin_name in self.plugins:
481-
self.plugin_options.setdefault(plugin_name, {})[key] = value # type: ignore
481+
self.plugin_options.setdefault(plugin_name, {})[key] = value # type: ignore[index]
482482
return
483483

484484
# If we get here, we didn't find the option.
@@ -496,13 +496,13 @@ def get_option(self, option_name: str) -> Optional[TConfigValueOut]:
496496
"""
497497
# Special-cased options.
498498
if option_name == "paths":
499-
return self.paths # type: ignore
499+
return self.paths # type: ignore[return-value]
500500

501501
# Check all the hard-coded options.
502502
for option_spec in self.CONFIG_FILE_OPTIONS:
503503
attr, where = option_spec[:2]
504504
if where == option_name:
505-
return getattr(self, attr) # type: ignore
505+
return getattr(self, attr) # type: ignore[no-any-return]
506506

507507
# See if it's a plugin option.
508508
plugin_name, _, key = option_name.partition(":")

coverage/debug.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __init__(self, options: Iterable[str]) -> None:
105105

106106
def get_output(self) -> str:
107107
"""Get the output text from the `DebugControl`."""
108-
return cast(str, self.raw_output.getvalue()) # type: ignore
108+
return cast(str, self.raw_output.getvalue()) # type: ignore[union-attr]
109109

110110

111111
class NoDebugging(DebugControl):
@@ -424,7 +424,7 @@ def decorate_methods(
424424
private: bool = False,
425425
) -> Callable[..., Any]: # pragma: debugging
426426
"""A class decorator to apply a decorator to methods."""
427-
def _decorator(cls): # type: ignore
427+
def _decorator(cls): # type: ignore[no-untyped-def]
428428
for name, meth in inspect.getmembers(cls, inspect.isroutine):
429429
if name not in cls.__dict__:
430430
continue

coverage/files.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def canonical_filename(filename: str) -> str:
7373
if not os.path.isabs(filename):
7474
for path in [os.curdir] + sys.path:
7575
if path is None:
76-
continue # type: ignore
76+
continue # type: ignore[unreachable]
7777
f = os.path.join(path, filename)
7878
try:
7979
exists = os.path.exists(f)

tests/test_annotate.py

-2
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ def test_multi(self) -> None:
4343
cov = coverage.Coverage()
4444
self.start_import_stop(cov, "multi")
4545
cov.annotate()
46-
4746
compare(gold_path("annotate/multi"), ".", "*,cover")
4847

4948
def test_annotate_dir(self) -> None:
5049
self.make_multi()
5150
cov = coverage.Coverage(source=["."])
5251
self.start_import_stop(cov, "multi")
5352
cov.annotate(directory="out_anno_dir")
54-
5553
compare(gold_path("annotate/anno_dir"), "out_anno_dir", "*,cover")
5654

5755
def test_encoding(self) -> None:

0 commit comments

Comments
 (0)