From 4f381af4c5d85f7fd41681231c535da6b5a74f44 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 7 Nov 2022 19:20:47 +0000 Subject: [PATCH] Upgrade mypy to 0.990 (#9123) --- requirements-tests.txt | 2 +- stdlib/importlib/abc.pyi | 1 + test_cases/stdlib/asyncio/check_task.py | 2 +- test_cases/stdlib/builtins/check_dict.py | 6 ++++-- tests/stubtest_allowlists/py3_common.txt | 11 +++++++++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 421bea5ac..e84fccd25 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -5,7 +5,7 @@ flake8-bugbear==22.10.27 # must match .pre-commit-config.yaml flake8-noqa==1.2.9 # must match .pre-commit-config.yaml flake8-pyi==22.10.0 # must match .pre-commit-config.yaml isort==5.10.1 # must match .pre-commit-config.yaml -mypy==0.982 +mypy==0.990 packaging==21.3 pathspec pycln==2.1.1 # must match .pre-commit-config.yaml diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 7abe26d97..c961fb2e1 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -179,6 +179,7 @@ if sys.version_info >= (3, 9): self, mode: str, buffering: int = ..., encoding: str | None = ..., errors: str | None = ..., newline: str | None = ... ) -> IO[Any]: ... @property + @abstractmethod def name(self) -> str: ... @abstractmethod def __truediv__(self, child: str) -> Traversable: ... diff --git a/test_cases/stdlib/asyncio/check_task.py b/test_cases/stdlib/asyncio/check_task.py index d674c44ab..69bcf8f78 100644 --- a/test_cases/stdlib/asyncio/check_task.py +++ b/test_cases/stdlib/asyncio/check_task.py @@ -15,7 +15,7 @@ class Waiter: async def foo() -> int: - ... + return 42 async def main() -> None: diff --git a/test_cases/stdlib/builtins/check_dict.py b/test_cases/stdlib/builtins/check_dict.py index b2def8b9a..3ba6ce89a 100644 --- a/test_cases/stdlib/builtins/check_dict.py +++ b/test_cases/stdlib/builtins/check_dict.py @@ -16,11 +16,13 @@ _VT = TypeVar("_VT") class KeysAndGetItem(Generic[_KT, _VT]): + data: Dict[_KT, _VT] + def keys(self) -> Iterable[_KT]: - ... + return self.data.keys() def __getitem__(self, __k: _KT) -> _VT: - ... + return self.data[__k] kt1: KeysAndGetItem[int, str] = KeysAndGetItem() diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 29241c85f..03db863c0 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -438,6 +438,17 @@ types.WrapperDescriptorType.__get__ typing.[A-Z]\w+ typing_extensions\..* +# These are abstract properties at runtime, +# but marking them as such in the stub breaks half the the typed-Python ecosystem (see #8726) +typing.IO.closed +typing.IO.mode +typing.IO.name +typing.TextIO.buffer +typing.TextIO.encoding +typing.TextIO.errors +typing.TextIO.line_buffering +typing.TextIO.newlines + # Typing-related weirdness _collections_abc.Callable _typeshed.* # Utility types for typeshed, doesn't exist at runtime