Skip to content

Commit b430318

Browse files
ilevkivskyigvanrossum
authored andcommitted
Fix non-subscriptable type aliases (#993)
1 parent 52da2a1 commit b430318

File tree

4 files changed

+50
-49
lines changed

4 files changed

+50
-49
lines changed

stdlib/2/ConfigParser.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Any, IO, Sequence, Tuple, Union
1+
from typing import Any, IO, Sequence, Tuple, Union, List, Dict
22

3-
__all__ = ... # type: list[str]
3+
__all__ = ... # type: List[str]
44
DEFAULTSECT = ... # type: str
55
MAX_INTERPOLATION_DEPTH = ... # type: int
66

@@ -42,7 +42,7 @@ class InterpolationDepthError(InterpolationError):
4242

4343
class ParsingError(Error):
4444
filename = ... # type: str
45-
errors = ... # type: list[Tuple[Any, Any]]
45+
errors = ... # type: List[Tuple[Any, Any]]
4646
def __init__(self, filename: str) -> None: ...
4747
def append(self, lineno: Any, line: Any) -> None: ...
4848

@@ -60,20 +60,20 @@ class RawConfigParser:
6060
SECTCRE = ... # type: Any
6161
OPTCRE = ... # type: Any
6262
OPTCRE_NV = ... # type: Any
63-
def __init__(self, defaults: dict[Any, Any] = ..., dict_type: Any = ..., allow_no_value: bool = ...) -> None: ...
64-
def defaults(self) -> dict[Any, Any]: ...
65-
def sections(self) -> list[str]: ...
63+
def __init__(self, defaults: Dict[Any, Any] = ..., dict_type: Any = ..., allow_no_value: bool = ...) -> None: ...
64+
def defaults(self) -> Dict[Any, Any]: ...
65+
def sections(self) -> List[str]: ...
6666
def add_section(self, section: str) -> None: ...
6767
def has_section(self, section: str) -> bool: ...
68-
def options(self, section: str) -> list[str]: ...
69-
def read(self, filenames: Union[str, Sequence[str]]) -> list[str]: ...
68+
def options(self, section: str) -> List[str]: ...
69+
def read(self, filenames: Union[str, Sequence[str]]) -> List[str]: ...
7070
def readfp(self, fp: IO[str], filename: str = ...) -> None: ...
7171
def get(self, section: str, option: str) -> str: ...
72-
def items(self, section: str) -> list[Tuple[Any, Any]]: ...
72+
def items(self, section: str) -> List[Tuple[Any, Any]]: ...
7373
def _get(self, section: str, conv: type, option: str) -> Any: ...
7474
def getint(self, section: str, option: str) -> int: ...
7575
def getfloat(self, section: str, option: str) -> float: ...
76-
_boolean_states = ... # type: dict[str, bool]
76+
_boolean_states = ... # type: Dict[str, bool]
7777
def getboolean(self, section: str, option: str) -> bool: ...
7878
def optionxform(self, optionstr: str) -> str: ...
7979
def has_option(self, section: str, option: str) -> bool: ...
@@ -86,7 +86,7 @@ class RawConfigParser:
8686
class ConfigParser(RawConfigParser):
8787
_KEYCRE = ... # type: Any
8888
def get(self, section: str, option: str, raw: bool = ..., vars: dict = ...) -> Any: ...
89-
def items(self, section: str, raw: bool = ..., vars: dict = ...) -> list[Tuple[str, Any]]: ...
89+
def items(self, section: str, raw: bool = ..., vars: dict = ...) -> List[Tuple[str, Any]]: ...
9090
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
9191
def _interpolation_replace(self, match: Any) -> str: ...
9292

stdlib/2/__builtin__.pyi

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -586,33 +586,33 @@ class set(MutableSet[_T], Generic[_T]):
586586
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
587587
def add(self, element: _T) -> None: ...
588588
def clear(self) -> None: ...
589-
def copy(self) -> set[_T]: ...
590-
def difference(self, *s: Iterable[Any]) -> set[_T]: ...
589+
def copy(self) -> Set[_T]: ...
590+
def difference(self, *s: Iterable[Any]) -> Set[_T]: ...
591591
def difference_update(self, *s: Iterable[Any]) -> None: ...
592592
def discard(self, element: _T) -> None: ...
593-
def intersection(self, *s: Iterable[Any]) -> set[_T]: ...
593+
def intersection(self, *s: Iterable[Any]) -> Set[_T]: ...
594594
def intersection_update(self, *s: Iterable[Any]) -> None: ...
595595
def isdisjoint(self, s: Iterable[Any]) -> bool: ...
596596
def issubset(self, s: Iterable[Any]) -> bool: ...
597597
def issuperset(self, s: Iterable[Any]) -> bool: ...
598598
def pop(self) -> _T: ...
599599
def remove(self, element: _T) -> None: ...
600-
def symmetric_difference(self, s: Iterable[_T]) -> set[_T]: ...
600+
def symmetric_difference(self, s: Iterable[_T]) -> Set[_T]: ...
601601
def symmetric_difference_update(self, s: Iterable[_T]) -> None: ...
602-
def union(self, *s: Iterable[_T]) -> set[_T]: ...
602+
def union(self, *s: Iterable[_T]) -> Set[_T]: ...
603603
def update(self, *s: Iterable[_T]) -> None: ...
604604
def __len__(self) -> int: ...
605605
def __contains__(self, o: object) -> bool: ...
606606
def __iter__(self) -> Iterator[_T]: ...
607607
def __str__(self) -> str: ...
608-
def __and__(self, s: AbstractSet[Any]) -> set[_T]: ...
609-
def __iand__(self, s: AbstractSet[Any]) -> set[_T]: ...
610-
def __or__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
611-
def __ior__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
612-
def __sub__(self, s: AbstractSet[Any]) -> set[_T]: ...
613-
def __isub__(self, s: AbstractSet[Any]) -> set[_T]: ...
614-
def __xor__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
615-
def __ixor__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
608+
def __and__(self, s: AbstractSet[Any]) -> Set[_T]: ...
609+
def __iand__(self, s: AbstractSet[Any]) -> Set[_T]: ...
610+
def __or__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ...
611+
def __ior__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ...
612+
def __sub__(self, s: AbstractSet[Any]) -> Set[_T]: ...
613+
def __isub__(self, s: AbstractSet[Any]) -> Set[_T]: ...
614+
def __xor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ...
615+
def __ixor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ...
616616
def __le__(self, s: AbstractSet[Any]) -> bool: ...
617617
def __lt__(self, s: AbstractSet[Any]) -> bool: ...
618618
def __ge__(self, s: AbstractSet[Any]) -> bool: ...

stdlib/3/builtins.pyi

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -636,33 +636,33 @@ class set(MutableSet[_T], Generic[_T]):
636636
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
637637
def add(self, element: _T) -> None: ...
638638
def clear(self) -> None: ...
639-
def copy(self) -> set[_T]: ...
640-
def difference(self, *s: Iterable[Any]) -> set[_T]: ...
639+
def copy(self) -> Set[_T]: ...
640+
def difference(self, *s: Iterable[Any]) -> Set[_T]: ...
641641
def difference_update(self, *s: Iterable[Any]) -> None: ...
642642
def discard(self, element: _T) -> None: ...
643-
def intersection(self, *s: Iterable[Any]) -> set[_T]: ...
643+
def intersection(self, *s: Iterable[Any]) -> Set[_T]: ...
644644
def intersection_update(self, *s: Iterable[Any]) -> None: ...
645645
def isdisjoint(self, s: Iterable[Any]) -> bool: ...
646646
def issubset(self, s: Iterable[Any]) -> bool: ...
647647
def issuperset(self, s: Iterable[Any]) -> bool: ...
648648
def pop(self) -> _T: ...
649649
def remove(self, element: _T) -> None: ...
650-
def symmetric_difference(self, s: Iterable[_T]) -> set[_T]: ...
650+
def symmetric_difference(self, s: Iterable[_T]) -> Set[_T]: ...
651651
def symmetric_difference_update(self, s: Iterable[_T]) -> None: ...
652-
def union(self, *s: Iterable[_T]) -> set[_T]: ...
652+
def union(self, *s: Iterable[_T]) -> Set[_T]: ...
653653
def update(self, *s: Iterable[_T]) -> None: ...
654654
def __len__(self) -> int: ...
655655
def __contains__(self, o: object) -> bool: ...
656656
def __iter__(self) -> Iterator[_T]: ...
657657
def __str__(self) -> str: ...
658-
def __and__(self, s: AbstractSet[Any]) -> set[_T]: ...
659-
def __iand__(self, s: AbstractSet[Any]) -> set[_T]: ...
660-
def __or__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
661-
def __ior__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
662-
def __sub__(self, s: AbstractSet[Any]) -> set[_T]: ...
663-
def __isub__(self, s: AbstractSet[Any]) -> set[_T]: ...
664-
def __xor__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
665-
def __ixor__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
658+
def __and__(self, s: AbstractSet[Any]) -> Set[_T]: ...
659+
def __iand__(self, s: AbstractSet[Any]) -> Set[_T]: ...
660+
def __or__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ...
661+
def __ior__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ...
662+
def __sub__(self, s: AbstractSet[Any]) -> Set[_T]: ...
663+
def __isub__(self, s: AbstractSet[Any]) -> Set[_T]: ...
664+
def __xor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ...
665+
def __ixor__(self, s: AbstractSet[_S]) -> Set[Union[_T, _S]]: ...
666666
def __le__(self, s: AbstractSet[Any]) -> bool: ...
667667
def __lt__(self, s: AbstractSet[Any]) -> bool: ...
668668
def __ge__(self, s: AbstractSet[Any]) -> bool: ...

stdlib/3/collections/__init__.pyi

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# These are not exported.
88
import sys
9+
import typing
910
from typing import (
1011
TypeVar, Generic, Dict, overload, List, Tuple,
1112
Callable, Any, Type, Optional, Union
@@ -128,16 +129,16 @@ class Counter(Dict[_T, int], Generic[_T]):
128129
@overload
129130
def update(self, m: Union[Iterable[_T], Iterable[Tuple[_T, int]]]) -> None: ...
130131

131-
def __add__(self, other: Counter[_T]) -> Counter[_T]: ...
132-
def __sub__(self, other: Counter[_T]) -> Counter[_T]: ...
133-
def __and__(self, other: Counter[_T]) -> Counter[_T]: ...
134-
def __or__(self, other: Counter[_T]) -> Counter[_T]: ...
135-
def __pos__(self) -> Counter[_T]: ...
136-
def __neg__(self) -> Counter[_T]: ...
137-
def __iadd__(self, other: Counter[_T]) -> Counter[_T]: ...
138-
def __isub__(self, other: Counter[_T]) -> Counter[_T]: ...
139-
def __iand__(self, other: Counter[_T]) -> Counter[_T]: ...
140-
def __ior__(self, other: Counter[_T]) -> Counter[_T]: ...
132+
def __add__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ...
133+
def __sub__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ...
134+
def __and__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ...
135+
def __or__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ...
136+
def __pos__(self) -> typing.Counter[_T]: ...
137+
def __neg__(self) -> typing.Counter[_T]: ...
138+
def __iadd__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ...
139+
def __isub__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ...
140+
def __iand__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ...
141+
def __ior__(self, other: typing.Counter[_T]) -> typing.Counter[_T]: ...
141142

142143
class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
143144
def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
@@ -176,10 +177,10 @@ if sys.version_info >= (3, 3):
176177
@property
177178
def maps(self) -> List[Mapping[_KT, _VT]]: ...
178179

179-
def new_child(self, m: Mapping[_KT, _VT] = ...) -> ChainMap[_KT, _VT]: ...
180+
def new_child(self, m: Mapping[_KT, _VT] = ...) -> typing.ChainMap[_KT, _VT]: ...
180181

181182
@property
182-
def parents(self) -> ChainMap[_KT, _VT]: ...
183+
def parents(self) -> typing.ChainMap[_KT, _VT]: ...
183184

184185
def __setitem__(self, k: _KT, v: _VT) -> None: ...
185186
def __delitem__(self, v: _KT) -> None: ...

0 commit comments

Comments
 (0)