Remove some no longer needed type-ignores
This commit is contained in:
parent
07f0eb26b4
commit
afea190797
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from typing import List
|
||||
from unittest import IsolatedAsyncioTestCase # type: ignore
|
||||
from unittest import IsolatedAsyncioTestCase
|
||||
|
||||
|
||||
teardowns: List[None] = []
|
||||
|
|
|
@ -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))"
|
||||
|
||||
|
|
Loading…
Reference in New Issue