@@ -3,11 +3,14 @@ from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
33from collections .abc import Iterable , MutableSequence
44from types import GenericAlias
55from typing import Any , ClassVar , Literal , SupportsIndex , TypeVar , overload
6- from typing_extensions import Self , TypeAlias
6+ from typing_extensions import Self , TypeAlias , deprecated
77
88_IntTypeCode : TypeAlias = Literal ["b" , "B" , "h" , "H" , "i" , "I" , "l" , "L" , "q" , "Q" ]
99_FloatTypeCode : TypeAlias = Literal ["f" , "d" ]
10- _UnicodeTypeCode : TypeAlias = Literal ["u" ]
10+ if sys .version_info >= (3 , 13 ):
11+ _UnicodeTypeCode : TypeAlias = Literal ["u" , "w" ]
12+ else :
13+ _UnicodeTypeCode : TypeAlias = Literal ["u" ]
1114_TypeCode : TypeAlias = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode
1215
1316_T = TypeVar ("_T" , int , float , str )
@@ -27,10 +30,23 @@ class array(MutableSequence[_T]):
2730 def __new__ (
2831 cls : type [array [float ]], typecode : _FloatTypeCode , initializer : bytes | bytearray | Iterable [float ] = ..., /
2932 ) -> array [float ]: ...
30- @overload
31- def __new__ (
32- cls : type [array [str ]], typecode : _UnicodeTypeCode , initializer : bytes | bytearray | Iterable [str ] = ..., /
33- ) -> array [str ]: ...
33+ if sys .version_info >= (3 , 13 ):
34+ @overload
35+ def __new__ (
36+ cls : type [array [str ]], typecode : Literal ["w" ], initializer : bytes | bytearray | Iterable [str ] = ..., /
37+ ) -> array [str ]: ...
38+ @overload
39+ @deprecated ("Deprecated since Python 3.3; will be removed in Python 3.16. Use 'w' typecode instead." )
40+ def __new__ (
41+ cls : type [array [str ]], typecode : Literal ["u" ], initializer : bytes | bytearray | Iterable [str ] = ..., /
42+ ) -> array [str ]: ...
43+ else :
44+ @overload
45+ @deprecated ("Deprecated since Python 3.3; will be removed in Python 3.16." )
46+ def __new__ (
47+ cls : type [array [str ]], typecode : Literal ["u" ], initializer : bytes | bytearray | Iterable [str ] = ..., /
48+ ) -> array [str ]: ...
49+
3450 @overload
3551 def __new__ (cls , typecode : str , initializer : Iterable [_T ], / ) -> Self : ...
3652 @overload
0 commit comments