From afea19079786761ee167e2bb4e0c90e3f44ba544 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 29 Jan 2021 20:40:43 +0200 Subject: Remove some no longer needed type-ignores --- src/_pytest/cacheprovider.py | 2 +- src/_pytest/monkeypatch.py | 2 +- src/_pytest/pytester.py | 10 +++------- src/_pytest/python.py | 3 +-- src/_pytest/python_api.py | 2 +- testing/example_scripts/unittest/test_unittest_asyncio.py | 2 +- testing/test_assertrewrite.py | 4 ++-- 7 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index 480319c03..585cebf6c 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -415,7 +415,7 @@ class NFPlugin: self.cached_nodeids.update(item.nodeid for item in items) def _get_increasing_order(self, items: Iterable[nodes.Item]) -> List[nodes.Item]: - return sorted(items, key=lambda item: item.fspath.mtime(), reverse=True) # type: ignore[no-any-return] + return sorted(items, key=lambda item: item.fspath.mtime(), reverse=True) def pytest_sessionfinish(self) -> None: config = self.config diff --git a/src/_pytest/monkeypatch.py b/src/_pytest/monkeypatch.py index ffef87173..2c4320656 100644 --- a/src/_pytest/monkeypatch.py +++ b/src/_pytest/monkeypatch.py @@ -91,7 +91,7 @@ def annotated_getattr(obj: object, name: str, ann: str) -> object: def derive_importpath(import_path: str, raising: bool) -> Tuple[str, object]: - if not isinstance(import_path, str) or "." not in import_path: # type: ignore[unreachable] + if not isinstance(import_path, str) or "." not in import_path: raise TypeError(f"must be absolute import path string, not {import_path!r}") module, attr = import_path.rsplit(".", 1) target = resolve(module) diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index d428654de..4fe6e288b 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1096,7 +1096,7 @@ class Pytester: class reprec: # type: ignore pass - reprec.ret = ret # type: ignore + reprec.ret = ret # Typically we reraise keyboard interrupts from the child run # because it's our user requesting interruption of the testing. @@ -1263,9 +1263,7 @@ class Pytester: Whether to also write an ``__init__.py`` file to the same directory to ensure it is a package. """ - # TODO: Remove type ignore in next mypy release (> 0.790). - # https://github.com/python/typeshed/pull/4582 - if isinstance(source, os.PathLike): # type: ignore[misc] + if isinstance(source, os.PathLike): path = self.path.joinpath(source) assert not withinit, "not supported for paths" else: @@ -1367,10 +1365,8 @@ class Pytester: """ __tracebackhide__ = True - # TODO: Remove type ignore in next mypy release. - # https://github.com/python/typeshed/pull/4582 cmdargs = tuple( - os.fspath(arg) if isinstance(arg, os.PathLike) else arg for arg in cmdargs # type: ignore[misc] + os.fspath(arg) if isinstance(arg, os.PathLike) else arg for arg in cmdargs ) p1 = self.path.joinpath("stdout") p2 = self.path.joinpath("stderr") diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 29ebd176b..3d903ff9b 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -139,8 +139,7 @@ def pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]: def pytest_generate_tests(metafunc: "Metafunc") -> None: for marker in metafunc.definition.iter_markers(name="parametrize"): - # TODO: Fix this type-ignore (overlapping kwargs). - metafunc.parametrize(*marker.args, **marker.kwargs, _param_mark=marker) # type: ignore[misc] + metafunc.parametrize(*marker.args, **marker.kwargs, _param_mark=marker) def pytest_configure(config: Config) -> None: diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 81ce4f895..7e0c86479 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -713,7 +713,7 @@ def raises( else: excepted_exceptions = expected_exception for exc in excepted_exceptions: - if not isinstance(exc, type) or not issubclass(exc, BaseException): # type: ignore[unreachable] + if not isinstance(exc, type) or not issubclass(exc, BaseException): msg = "expected exception must be a BaseException type, not {}" # type: ignore[unreachable] not_a = exc.__name__ if isinstance(exc, type) else type(exc).__name__ raise TypeError(msg.format(not_a)) diff --git a/testing/example_scripts/unittest/test_unittest_asyncio.py b/testing/example_scripts/unittest/test_unittest_asyncio.py index bbc752de5..1cd216860 100644 --- a/testing/example_scripts/unittest/test_unittest_asyncio.py +++ b/testing/example_scripts/unittest/test_unittest_asyncio.py @@ -1,5 +1,5 @@ from typing import List -from unittest import IsolatedAsyncioTestCase # type: ignore +from unittest import IsolatedAsyncioTestCase teardowns: List[None] = [] diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index ffe18260f..cba03406e 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -381,7 +381,7 @@ class TestAssertionRewrite: ) def f7() -> None: - assert False or x() # type: ignore[unreachable] + assert False or x() assert ( getmsg(f7, {"x": x}) @@ -471,7 +471,7 @@ class TestAssertionRewrite: assert getmsg(f1) == "assert ((3 % 2) and False)" def f2() -> None: - assert False or 4 % 2 # type: ignore[unreachable] + assert False or 4 % 2 assert getmsg(f2) == "assert (False or (4 % 2))" -- cgit v1.2.3