Update mypy 0.782 -> 0.790

This commit is contained in:
Ran Benita 2020-10-17 16:54:54 +03:00
parent e5e47c1097
commit 1b23a111d2
13 changed files with 20 additions and 24 deletions

View File

@ -49,7 +49,7 @@ repos:
hooks:
- id: python-use-type-annotations
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.782 # NOTE: keep this in sync with setup.cfg.
rev: v0.790 # NOTE: keep this in sync with setup.cfg.
hooks:
- id: mypy
files: ^(src/|testing/)

View File

@ -63,7 +63,7 @@ console_scripts =
[options.extras_require]
checkqa-mypy =
mypy==0.780
mypy==0.790
testing =
argcomplete
hypothesis>=3.56

View File

@ -382,7 +382,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)
return sorted(items, key=lambda item: item.fspath.mtime(), reverse=True) # type: ignore[no-any-return]
def pytest_sessionfinish(self) -> None:
config = self.config

View File

@ -380,8 +380,7 @@ class FDCaptureBinary:
self.syscapture = SysCapture(targetfd)
else:
self.tmpfile = EncodedFile(
# TODO: Remove type ignore, fixed in next mypy release.
TemporaryFile(buffering=0), # type: ignore[arg-type]
TemporaryFile(buffering=0),
encoding="utf-8",
errors="replace",
newline="",

View File

@ -150,9 +150,8 @@ def getfuncargnames(
p.name
for p in parameters.values()
if (
# TODO: Remove type ignore after https://github.com/python/typeshed/pull/4383
p.kind is Parameter.POSITIONAL_OR_KEYWORD # type: ignore[unreachable]
or p.kind is Parameter.KEYWORD_ONLY # type: ignore[unreachable]
p.kind is Parameter.POSITIONAL_OR_KEYWORD
or p.kind is Parameter.KEYWORD_ONLY
)
and p.default is Parameter.empty
)

View File

@ -1322,8 +1322,10 @@ 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
os.fspath(arg) if isinstance(arg, os.PathLike) else arg for arg in cmdargs # type: ignore[misc]
)
p1 = self.path.joinpath("stdout")
p2 = self.path.joinpath("stderr")

View File

@ -210,7 +210,7 @@ class ApproxScalar(ApproxBase):
# tolerances, i.e. non-numerics and infinities. Need to call abs to
# handle complex numbers, e.g. (inf + 1j).
if (not isinstance(self.expected, (Complex, Decimal))) or math.isinf(
abs(self.expected)
abs(self.expected) # type: ignore[arg-type]
):
return str(self.expected)
@ -253,8 +253,8 @@ class ApproxScalar(ApproxBase):
# Allow the user to control whether NaNs are considered equal to each
# other or not. The abs() calls are for compatibility with complex
# numbers.
if math.isnan(abs(self.expected)):
return self.nan_ok and math.isnan(abs(actual))
if math.isnan(abs(self.expected)): # type: ignore[arg-type]
return self.nan_ok and math.isnan(abs(actual)) # type: ignore[arg-type]
# Infinity shouldn't be approximately equal to anything but itself, but
# if there's a relative tolerance, it will be infinite and infinity
@ -262,7 +262,7 @@ class ApproxScalar(ApproxBase):
# case would have been short circuited above, so here we can just
# return false if the expected value is infinite. The abs() call is
# for compatibility with complex numbers.
if math.isinf(abs(self.expected)):
if math.isinf(abs(self.expected)): # type: ignore[arg-type]
return False
# Return true if the two numbers are within the tolerance.

View File

@ -77,7 +77,7 @@ def pytest_terminal_summary(terminalreporter: "TerminalReporter") -> None:
dlist.append(rep)
if not dlist:
return
dlist.sort(key=lambda x: x.duration)
dlist.sort(key=lambda x: x.duration) # type: ignore[no-any-return]
dlist.reverse()
if not durations:
tr.write_sep("=", "slowest durations")

View File

@ -1595,7 +1595,7 @@ class TestPyCacheDir:
if prefix:
if sys.version_info < (3, 8):
pytest.skip("pycache_prefix not available in py<38")
monkeypatch.setattr(sys, "pycache_prefix", prefix) # type:ignore
monkeypatch.setattr(sys, "pycache_prefix", prefix)
assert get_cache_dir(Path(source)) == Path(expected)

View File

@ -1606,7 +1606,7 @@ def test_stderr_write_returns_len(capsys):
def test_encodedfile_writelines(tmpfile: BinaryIO) -> None:
ef = capture.EncodedFile(tmpfile, encoding="utf-8")
with pytest.raises(TypeError):
ef.writelines([b"line1", b"line2"])
ef.writelines([b"line1", b"line2"]) # type: ignore[list-item]
assert ef.writelines(["line3", "line4"]) is None # type: ignore[func-returns-value]
ef.flush()
tmpfile.seek(0)

View File

@ -886,14 +886,9 @@ class TestPDB:
class TestDebuggingBreakpoints:
def test_supports_breakpoint_module_global(self):
"""
Test that supports breakpoint global marks on Python 3.7+ and not on
CPython 3.5, 2.7
"""
"""Test that supports breakpoint global marks on Python 3.7+."""
if sys.version_info >= (3, 7):
assert SUPPORTS_BREAKPOINT_BUILTIN is True
if sys.version_info.major == 3 and sys.version_info.minor == 5:
assert SUPPORTS_BREAKPOINT_BUILTIN is False # type: ignore[comparison-overlap]
@pytest.mark.skipif(
not SUPPORTS_BREAKPOINT_BUILTIN, reason="Requires breakpoint() builtin"

View File

@ -1049,7 +1049,7 @@ class TestLiterals:
("1e3", "999"),
# The current implementation doesn't understand that numbers inside
# strings shouldn't be treated as numbers:
pytest.param("'3.1416'", "'3.14'", marks=pytest.mark.xfail), # type: ignore
pytest.param("'3.1416'", "'3.14'", marks=pytest.mark.xfail),
],
)
def test_number_non_matches(self, pytester, expression, output):

View File

@ -1,3 +1,4 @@
import io
from typing import List
from typing import Union
@ -95,7 +96,7 @@ class TestPaste:
def mocked(url, data):
calls.append((url, data))
raise urllib.error.HTTPError(url, 400, "Bad request", None, None)
raise urllib.error.HTTPError(url, 400, "Bad request", {}, io.BytesIO())
monkeypatch.setattr(urllib.request, "urlopen", mocked)
return calls