Skip to content

Commit a297d59

Browse files
authored
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`.
1 parent 51d693c commit a297d59

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/_collections_abc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,8 @@ def _type_repr(obj):
517517
518518
Copied from :mod:`typing` since collections.abc
519519
shouldn't depend on that module.
520+
(Keep this roughly in sync with the typing version.)
520521
"""
521-
if isinstance(obj, GenericAlias):
522-
return repr(obj)
523522
if isinstance(obj, type):
524523
if obj.__module__ == 'builtins':
525524
return obj.__qualname__

Lib/typing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ def _type_repr(obj):
230230
typically enough to uniquely identify a type. For everything
231231
else, we fall back on repr(obj).
232232
"""
233+
# When changing this function, don't forget about
234+
# `_collections_abc._type_repr`, which does the same thing
235+
# and must be consistent with this one.
233236
if isinstance(obj, type):
234237
if obj.__module__ == 'builtins':
235238
return obj.__qualname__

0 commit comments

Comments
 (0)