Skip to content

Commit 939efdc

Browse files
sobolevnwarsaw
authored andcommitted
Add comments to {typing,_collections_abc}._type_repr about each other (python#102752)
Remove `if` condition in `_collections_abc._type_repr` that's no longer needed, bringing it in sync with `typing._type_repr`.
1 parent 807a421 commit 939efdc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/_collections_abc.py

+1-2
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

+3
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)