Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,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)
Expand Down
4 changes: 3 additions & 1 deletion Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``repr`` of ``Any`` subclasses.