Skip to content

Commit a9d231f

Browse files
CPython Developersyouknowone
authored andcommitted
Update _collections_abc from v3.14.2
1 parent 507400b commit a9d231f

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

Lib/_collections_abc.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,10 @@ def __new__(cls, origin, args):
485485
def __repr__(self):
486486
if len(self.__args__) == 2 and _is_param_expr(self.__args__[0]):
487487
return super().__repr__()
488+
from annotationlib import type_repr
488489
return (f'collections.abc.Callable'
489-
f'[[{", ".join([_type_repr(a) for a in self.__args__[:-1]])}], '
490-
f'{_type_repr(self.__args__[-1])}]')
490+
f'[[{", ".join([type_repr(a) for a in self.__args__[:-1]])}], '
491+
f'{type_repr(self.__args__[-1])}]')
491492

492493
def __reduce__(self):
493494
args = self.__args__
@@ -512,10 +513,6 @@ def __getitem__(self, item):
512513
new_args = (t_args, t_result)
513514
return _CallableGenericAlias(Callable, tuple(new_args))
514515

515-
# TODO: RUSTPYTHON; patch for common call
516-
def __or__(self, other):
517-
super().__or__(other)
518-
519516
def _is_param_expr(obj):
520517
"""Checks if obj matches either a list of types, ``...``, ``ParamSpec`` or
521518
``_ConcatenateGenericAlias`` from typing.py
@@ -528,23 +525,6 @@ def _is_param_expr(obj):
528525
names = ('ParamSpec', '_ConcatenateGenericAlias')
529526
return obj.__module__ == 'typing' and any(obj.__name__ == name for name in names)
530527

531-
def _type_repr(obj):
532-
"""Return the repr() of an object, special-casing types (internal helper).
533-
534-
Copied from :mod:`typing` since collections.abc
535-
shouldn't depend on that module.
536-
(Keep this roughly in sync with the typing version.)
537-
"""
538-
if isinstance(obj, type):
539-
if obj.__module__ == 'builtins':
540-
return obj.__qualname__
541-
return f'{obj.__module__}.{obj.__qualname__}'
542-
if obj is Ellipsis:
543-
return '...'
544-
if isinstance(obj, FunctionType):
545-
return obj.__name__
546-
return repr(obj)
547-
548528

549529
class Callable(metaclass=ABCMeta):
550530

@@ -1077,6 +1057,7 @@ def count(self, value):
10771057

10781058
Sequence.register(tuple)
10791059
Sequence.register(str)
1060+
Sequence.register(bytes)
10801061
Sequence.register(range)
10811062
Sequence.register(memoryview)
10821063

@@ -1183,4 +1164,4 @@ def __iadd__(self, values):
11831164

11841165

11851166
MutableSequence.register(list)
1186-
MutableSequence.register(bytearray) # Multiply inheriting, see ByteString
1167+
MutableSequence.register(bytearray)

0 commit comments

Comments
 (0)