Skip to content

Commit 38a3e30

Browse files
authored
Merge pull request #8296 from bluetech/mypy-800-ignores
Remove some no longer needed type-ignores
2 parents 07f0eb2 + afea190 commit 38a3e30

File tree

7 files changed

+10
-15
lines changed

7 files changed

+10
-15
lines changed

src/_pytest/cacheprovider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def pytest_collection_modifyitems(
415415
self.cached_nodeids.update(item.nodeid for item in items)
416416

417417
def _get_increasing_order(self, items: Iterable[nodes.Item]) -> List[nodes.Item]:
418-
return sorted(items, key=lambda item: item.fspath.mtime(), reverse=True) # type: ignore[no-any-return]
418+
return sorted(items, key=lambda item: item.fspath.mtime(), reverse=True)
419419

420420
def pytest_sessionfinish(self) -> None:
421421
config = self.config

src/_pytest/monkeypatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def annotated_getattr(obj: object, name: str, ann: str) -> object:
9191

9292

9393
def derive_importpath(import_path: str, raising: bool) -> Tuple[str, object]:
94-
if not isinstance(import_path, str) or "." not in import_path: # type: ignore[unreachable]
94+
if not isinstance(import_path, str) or "." not in import_path:
9595
raise TypeError(f"must be absolute import path string, not {import_path!r}")
9696
module, attr = import_path.rsplit(".", 1)
9797
target = resolve(module)

src/_pytest/pytester.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ def pytest_configure(x, config: Config) -> None:
10961096
class reprec: # type: ignore
10971097
pass
10981098

1099-
reprec.ret = ret # type: ignore
1099+
reprec.ret = ret
11001100

11011101
# Typically we reraise keyboard interrupts from the child run
11021102
# because it's our user requesting interruption of the testing.
@@ -1263,9 +1263,7 @@ def getmodulecol(
12631263
Whether to also write an ``__init__.py`` file to the same
12641264
directory to ensure it is a package.
12651265
"""
1266-
# TODO: Remove type ignore in next mypy release (> 0.790).
1267-
# https://github.com/python/typeshed/pull/4582
1268-
if isinstance(source, os.PathLike): # type: ignore[misc]
1266+
if isinstance(source, os.PathLike):
12691267
path = self.path.joinpath(source)
12701268
assert not withinit, "not supported for paths"
12711269
else:
@@ -1367,10 +1365,8 @@ def run(
13671365
"""
13681366
__tracebackhide__ = True
13691367

1370-
# TODO: Remove type ignore in next mypy release.
1371-
# https://github.com/python/typeshed/pull/4582
13721368
cmdargs = tuple(
1373-
os.fspath(arg) if isinstance(arg, os.PathLike) else arg for arg in cmdargs # type: ignore[misc]
1369+
os.fspath(arg) if isinstance(arg, os.PathLike) else arg for arg in cmdargs
13741370
)
13751371
p1 = self.path.joinpath("stdout")
13761372
p2 = self.path.joinpath("stderr")

src/_pytest/python.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ def pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]:
139139

140140
def pytest_generate_tests(metafunc: "Metafunc") -> None:
141141
for marker in metafunc.definition.iter_markers(name="parametrize"):
142-
# TODO: Fix this type-ignore (overlapping kwargs).
143-
metafunc.parametrize(*marker.args, **marker.kwargs, _param_mark=marker) # type: ignore[misc]
142+
metafunc.parametrize(*marker.args, **marker.kwargs, _param_mark=marker)
144143

145144

146145
def pytest_configure(config: Config) -> None:

src/_pytest/python_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def raises(
713713
else:
714714
excepted_exceptions = expected_exception
715715
for exc in excepted_exceptions:
716-
if not isinstance(exc, type) or not issubclass(exc, BaseException): # type: ignore[unreachable]
716+
if not isinstance(exc, type) or not issubclass(exc, BaseException):
717717
msg = "expected exception must be a BaseException type, not {}" # type: ignore[unreachable]
718718
not_a = exc.__name__ if isinstance(exc, type) else type(exc).__name__
719719
raise TypeError(msg.format(not_a))

testing/example_scripts/unittest/test_unittest_asyncio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import List
2-
from unittest import IsolatedAsyncioTestCase # type: ignore
2+
from unittest import IsolatedAsyncioTestCase
33

44

55
teardowns: List[None] = []

testing/test_assertrewrite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def f6() -> None:
381381
)
382382

383383
def f7() -> None:
384-
assert False or x() # type: ignore[unreachable]
384+
assert False or x()
385385

386386
assert (
387387
getmsg(f7, {"x": x})
@@ -471,7 +471,7 @@ def f1() -> None:
471471
assert getmsg(f1) == "assert ((3 % 2) and False)"
472472

473473
def f2() -> None:
474-
assert False or 4 % 2 # type: ignore[unreachable]
474+
assert False or 4 % 2
475475

476476
assert getmsg(f2) == "assert (False or (4 % 2))"
477477

0 commit comments

Comments
 (0)