mirror of
https://github.com/python/cpython
synced 2024-09-04 15:56:13 +00:00
gh-95987: Fix repr
of Any
type subclasses (#96412)
This commit is contained in:
parent
6d791a9736
commit
4217393aee
|
@ -113,6 +113,12 @@ def test_any_instance_type_error(self):
|
|||
def test_repr(self):
|
||||
self.assertEqual(repr(Any), 'typing.Any')
|
||||
|
||||
class Sub(Any): pass
|
||||
self.assertEqual(
|
||||
repr(Sub),
|
||||
"<class 'test.test_typing.AnyTests.test_repr.<locals>.Sub'>",
|
||||
)
|
||||
|
||||
def test_errors(self):
|
||||
with self.assertRaises(TypeError):
|
||||
issubclass(42, Any)
|
||||
|
|
|
@ -493,7 +493,9 @@ def __instancecheck__(self, obj):
|
|||
return super().__instancecheck__(obj)
|
||||
|
||||
def __repr__(self):
|
||||
return "typing.Any"
|
||||
if self is Any:
|
||||
return "typing.Any"
|
||||
return super().__repr__() # respect to subclasses
|
||||
|
||||
|
||||
class Any(metaclass=_AnyMeta):
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix ``repr`` of ``Any`` subclasses.
|
Loading…
Reference in a new issue