fix typing issues in mypy 0.920

This commit is contained in:
Anthony Sottile
2021-12-21 20:42:32 -05:00
parent e358bc65a8
commit c69b84f236
8 changed files with 23 additions and 16 deletions

View File

@@ -332,8 +332,7 @@ def test_findsource(monkeypatch) -> None:
lines = ["if 1:\n", " def x():\n", " pass\n"]
co = compile("".join(lines), filename, "exec")
# Type ignored because linecache.cache is private.
monkeypatch.setitem(linecache.cache, filename, (1, None, lines, filename)) # type: ignore[attr-defined]
monkeypatch.setitem(linecache.cache, filename, (1, None, lines, filename))
src, lineno = findsource(co)
assert src is not None

View File

@@ -1057,7 +1057,7 @@ class TestAssertionRewriteHookDetails:
e = OSError()
e.errno = 10
raise e
yield # type:ignore[unreachable]
yield
monkeypatch.setattr(
_pytest.assertion.rewrite, "atomic_write", atomic_write_failed

View File

@@ -14,7 +14,7 @@ def test_item_fspath(pytester: pytest.Pytester) -> None:
items2, hookrec = pytester.inline_genitems(item.nodeid)
(item2,) = items2
assert item2.name == item.name
assert item2.fspath == item.fspath # type: ignore[attr-defined]
assert item2.fspath == item.fspath
assert item2.path == item.path

View File

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

View File

@@ -114,13 +114,13 @@ class TestDeprecatedCall:
# Type ignored because `onceregistry` and `filters` are not
# documented API.
onceregistry = warnings.onceregistry.copy() # type: ignore
filters = warnings.filters[:] # type: ignore
filters = warnings.filters[:]
warn = warnings.warn
warn_explicit = warnings.warn_explicit
self.test_deprecated_call_raises()
self.test_deprecated_call()
assert onceregistry == warnings.onceregistry # type: ignore
assert filters == warnings.filters # type: ignore
assert filters == warnings.filters
assert warn is warnings.warn
assert warn_explicit is warnings.warn_explicit