@@ -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-
519516def _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
549529class Callable (metaclass = ABCMeta ):
550530
@@ -1077,6 +1057,7 @@ def count(self, value):
10771057
10781058Sequence .register (tuple )
10791059Sequence .register (str )
1060+ Sequence .register (bytes )
10801061Sequence .register (range )
10811062Sequence .register (memoryview )
10821063
@@ -1183,4 +1164,4 @@ def __iadd__(self, values):
11831164
11841165
11851166MutableSequence .register (list )
1186- MutableSequence .register (bytearray ) # Multiply inheriting, see ByteString
1167+ MutableSequence .register (bytearray )
0 commit comments