From 57c5e2f04fdf949d4975f397be5b6d70d720d899 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 20 Feb 2021 10:33:15 -0700 Subject: [PATCH 1/3] Removed conditional import from _collections_abc within collections/__init__.pyi. I don't know why this conditional was added, but it breaks type checking for 3.10 because a bunch of symbols used within this file are not defined. --- stdlib/collections/__init__.pyi | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index a667955db27b..2787fcfdffe0 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -2,8 +2,7 @@ import sys import typing from typing import Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, overload -if sys.version_info < (3, 10): - from _collections_abc import * +from _collections_abc import * _S = TypeVar("_S") _T = TypeVar("_T") @@ -103,7 +102,7 @@ class UserString(Sequence[str]): def center(self: _UserStringT, width: int, *args: Any) -> _UserStringT: ... def count(self, sub: Union[str, UserString], start: int = ..., end: int = ...) -> int: ... if sys.version_info >= (3, 8): - def encode(self: _UserStringT, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> bytes: ... + def encode(self: UserString, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> bytes: ... else: def encode(self: _UserStringT, encoding: Optional[str] = ..., errors: Optional[str] = ...) -> _UserStringT: ... def endswith(self, suffix: Union[str, Tuple[str, ...]], start: Optional[int] = ..., end: Optional[int] = ...) -> bool: ... From 3b7006eff9f6046cd842f853d744cf941238d160 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 20 Feb 2021 19:21:38 -0700 Subject: [PATCH 2/3] Fixed collections/__init__.pyi so it doesn't depend on _collections_abc. --- stdlib/collections/__init__.pyi | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 2787fcfdffe0..27defa4e1f00 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,8 +1,27 @@ import sys -import typing -from typing import Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, overload - -from _collections_abc import * +from typing import ( + Any, + Callable, + Dict, + Generic, + ItemsView, + Iterable, + Iterator, + KeysView, + List, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Reversible, + Sequence, + Tuple, + Type, + TypeVar, + Union, + ValuesView, + overload, +) _S = TypeVar("_S") _T = TypeVar("_T") @@ -280,9 +299,9 @@ class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]): def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ... @property def maps(self) -> List[Mapping[_KT, _VT]]: ... - def new_child(self, m: Mapping[_KT, _VT] = ...) -> typing.ChainMap[_KT, _VT]: ... + def new_child(self, m: Mapping[_KT, _VT] = ...) -> ChainMap[_KT, _VT]: ... @property - def parents(self) -> typing.ChainMap[_KT, _VT]: ... + def parents(self) -> ChainMap[_KT, _VT]: ... def __setitem__(self, k: _KT, v: _VT) -> None: ... def __delitem__(self, v: _KT) -> None: ... def __getitem__(self, k: _KT) -> _VT: ... From 47d6bebc2bbdb5e10bfbed9da22eb8bce81d07c8 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 20 Feb 2021 19:31:03 -0700 Subject: [PATCH 3/3] Try again --- stdlib/collections/__init__.pyi | 41 +++++++++++++++------------------ 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 27defa4e1f00..c7633fcdd57a 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,27 +1,22 @@ import sys -from typing import ( - Any, - Callable, - Dict, - Generic, - ItemsView, - Iterable, - Iterator, - KeysView, - List, - Mapping, - MutableMapping, - MutableSequence, - Optional, - Reversible, - Sequence, - Tuple, - Type, - TypeVar, - Union, - ValuesView, - overload, -) +from typing import Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, overload + +if sys.version_info < (3, 10): + from _collections_abc import * +else: + from typing import ( + Callable, + ItemsView, + Iterable, + Iterator, + KeysView, + Mapping, + MutableMapping, + MutableSequence, + Reversible, + Sequence, + ValuesView, + ) _S = TypeVar("_S") _T = TypeVar("_T")