From 2a9374d0c72fce732a5cd6ddc33c35c21c83c0b6 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Mon, 7 Nov 2022 18:47:55 +0000 Subject: [PATCH 1/5] Upgrade mypy to 0.990 --- requirements-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 421bea5ac52f..e84fccd25e21 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 From 7f49e8c10265a3560ad24a9bd1c867acae542130 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Mon, 7 Nov 2022 18:55:49 +0000 Subject: [PATCH 2/5] Fix stubtest --- stdlib/importlib/abc.pyi | 1 + tests/stubtest_allowlists/py3_common.txt | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 7abe26d97268..c961fb2e1f9e 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/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 29241c85f051..6b457f26e046 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 +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 From 0a16ae176a96dbbabd4409640f3e4af9e07c2c90 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 7 Nov 2022 18:57:25 +0000 Subject: [PATCH 3/5] Improve comment --- tests/stubtest_allowlists/py3_common.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 6b457f26e046..03db863c07d3 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -439,7 +439,7 @@ 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 +# 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 From deb804bf98c1b222deca6be99dc2457a1b07adea Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Mon, 7 Nov 2022 19:03:37 +0000 Subject: [PATCH 4/5] Fix test cases flagged by the new [empty-body] check --- test_cases/stdlib/asyncio/check_task.py | 2 +- test_cases/stdlib/builtins/check_dict.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test_cases/stdlib/asyncio/check_task.py b/test_cases/stdlib/asyncio/check_task.py index d674c44abb8b..69bcf8f782aa 100644 --- a/test_cases/stdlib/asyncio/check_task.py +++ b/test_cases/stdlib/asyncio/check_task.py @@ -15,7 +15,7 @@ async def join(self) -> None: 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 b2def8b9a017..b4cc7e238b75 100644 --- a/test_cases/stdlib/builtins/check_dict.py +++ b/test_cases/stdlib/builtins/check_dict.py @@ -16,11 +16,13 @@ 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() From bcd2d87449b02da1011fc4b4bac9ccf040009771 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 7 Nov 2022 19:06:24 +0000 Subject: [PATCH 5/5] Capital-D dict like it's 2016 --- test_cases/stdlib/builtins/check_dict.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_cases/stdlib/builtins/check_dict.py b/test_cases/stdlib/builtins/check_dict.py index b4cc7e238b75..3ba6ce89a7a4 100644 --- a/test_cases/stdlib/builtins/check_dict.py +++ b/test_cases/stdlib/builtins/check_dict.py @@ -16,7 +16,7 @@ class KeysAndGetItem(Generic[_KT, _VT]): - data: dict[_KT, _VT] + data: Dict[_KT, _VT] def keys(self) -> Iterable[_KT]: return self.data.keys()