Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add comments to {typing,_collections_abc}._type_repr abouth each other
  • Loading branch information
sobolevn committed Mar 16, 2023
commit 1a4fd9f146ac4416ae7ac5f5d1b74f0d23614941
5 changes: 3 additions & 2 deletions Lib/_collections_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,9 @@ def _type_repr(obj):
Copied from :mod:`typing` since collections.abc
shouldn't depend on that module.
Comment thread
sobolevn marked this conversation as resolved.
"""
if isinstance(obj, GenericAlias):
return repr(obj)
# When changing this function, don't forget about
# `typing._type_repr` function that does the same thing
# and must be consistent with this one.
Comment thread
AlexWaygood marked this conversation as resolved.
Outdated
if isinstance(obj, type):
if obj.__module__ == 'builtins':
return obj.__qualname__
Expand Down
3 changes: 3 additions & 0 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ def _type_repr(obj):
typically enough to uniquely identify a type. For everything
else, we fall back on repr(obj).
"""
# When changing this function, don't forget about
# `_collections_abc._type_repr` function that does the same thing
Comment thread
AlexWaygood marked this conversation as resolved.
Outdated
# and must be consistent with this one.
if isinstance(obj, type):
if obj.__module__ == 'builtins':
return obj.__qualname__
Expand Down