Update array with more precise type for typecodes (#3994)

Fixes #3946
This commit is contained in:
Steve Dignam
2020-05-15 05:55:40 -04:00
committed by GitHub
parent 6dca3f7fc5
commit e5dcf06c9e

View File

@@ -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: ...