mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
Add comments to {typing,_collections_abc}._type_repr about each other (#102752)
Remove `if` condition in `_collections_abc._type_repr` that's no longer needed, bringing it in sync with `typing._type_repr`.
This commit is contained in:
parent
51d693c584
commit
a297d59609
2 changed files with 4 additions and 2 deletions
|
|
@ -517,9 +517,8 @@ def _type_repr(obj):
|
|||
|
||||
Copied from :mod:`typing` since collections.abc
|
||||
shouldn't depend on that module.
|
||||
(Keep this roughly in sync with the typing version.)
|
||||
"""
|
||||
if isinstance(obj, GenericAlias):
|
||||
return repr(obj)
|
||||
if isinstance(obj, type):
|
||||
if obj.__module__ == 'builtins':
|
||||
return obj.__qualname__
|
||||
|
|
|
|||
|
|
@ -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`, which does the same thing
|
||||
# and must be consistent with this one.
|
||||
if isinstance(obj, type):
|
||||
if obj.__module__ == 'builtins':
|
||||
return obj.__qualname__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue