]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add comments to `{typing,_collections_abc}._type_repr` about each other (#102752)
authorNikita Sobolev <mail@sobolevn.me>
Thu, 16 Mar 2023 13:05:38 +0000 (16:05 +0300)
committerGitHub <noreply@github.com>
Thu, 16 Mar 2023 13:05:38 +0000 (13:05 +0000)
Remove `if` condition in `_collections_abc._type_repr` that's no longer needed, bringing it in sync with `typing._type_repr`.

Lib/_collections_abc.py
Lib/typing.py

index c62233b81a5c95c4b9a15ccfbea19f7d6aad18bd..f86b91a5e6fb0d441924f4772926699d03f0da0d 100644 (file)
@@ -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__
index ab3343956761597635322c1469156e500e4549e0..3ee9679e50c0c411751c09250055b5a2e758b9cb 100644 (file)
@@ -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__