@@ -3,11 +3,14 @@ from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
3
3
from collections .abc import Iterable , MutableSequence
4
4
from types import GenericAlias
5
5
from typing import Any , ClassVar , Literal , SupportsIndex , TypeVar , overload
6
- from typing_extensions import Self , TypeAlias
6
+ from typing_extensions import Self , TypeAlias , deprecated
7
7
8
8
_IntTypeCode : TypeAlias = Literal ["b" , "B" , "h" , "H" , "i" , "I" , "l" , "L" , "q" , "Q" ]
9
9
_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" ]
11
14
_TypeCode : TypeAlias = _IntTypeCode | _FloatTypeCode | _UnicodeTypeCode
12
15
13
16
_T = TypeVar ("_T" , int , float , str )
@@ -27,10 +30,23 @@ class array(MutableSequence[_T]):
27
30
def __new__ (
28
31
cls : type [array [float ]], typecode : _FloatTypeCode , initializer : bytes | bytearray | Iterable [float ] = ..., /
29
32
) -> 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
+
34
50
@overload
35
51
def __new__ (cls , typecode : str , initializer : Iterable [_T ], / ) -> Self : ...
36
52
@overload
0 commit comments