diff --git a/stdlib/2and3/array.pyi b/stdlib/2and3/array.pyi index 4f0b8a2cb..5b9c1256e 100644 --- a/stdlib/2and3/array.pyi +++ b/stdlib/2and3/array.pyi @@ -5,6 +5,12 @@ import sys from typing import (Any, BinaryIO, Generic, Iterable, Iterator, List, MutableSequence, overload, Text, Tuple, TypeVar, Union) +from typing_extensions import Literal + +_IntTypeCode = Literal['b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q'] +_FloatTypeCode = Literal['f', 'd'] +_UnicodeTypeCode = Literal['u'] +_TypeCode = Union[_IntTypeCode, _FloatTypeCode, _UnicodeTypeCode] _T = TypeVar('_T', int, float, Text) @@ -12,8 +18,18 @@ if sys.version_info >= (3,): typecodes: str class array(MutableSequence[_T], Generic[_T]): - typecode: str + typecode: _TypeCode itemsize: int + @overload + def __init__(self: array[int], typecode: _IntTypeCode, + __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + @overload + def __init__(self: array[float], typecode: _FloatTypeCode, + __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + @overload + def __init__(self: array[Text], typecode: _UnicodeTypeCode, + __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... + @overload def __init__(self, typecode: str, __initializer: Union[bytes, Iterable[_T]] = ...) -> None: ... def append(self, __v: _T) -> None: ...