This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients AlexWaygood, BTaskaya, JelleZijlstra, eric.smith, gvanrossum, joperez, kj, levkivskyi, lukasz.langa, miss-islington, n_rosenstein, sobolevn
Date 2022-01-25.20:58:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1643144327.1.0.689922798222.issue41370@roundup.psfhosted.org>
In-reply-to
Content
Here's a patch that doesn't do it right but illustrates the point:

diff --git a/Lib/typing.py b/Lib/typing.py
index 972b8ba24b..4616db60c3 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1807,6 +1807,12 @@ def get_type_hints(obj, globalns=None, localns=None, include_extras=False):
                     value = type(None)
                 if isinstance(value, str):
                     value = ForwardRef(value, is_argument=False, is_class=True)
+                elif isinstance(value, types.GenericAlias):
+                    args = tuple(
+                        ForwardRef(arg) if isinstance(arg, str) else args
+                        for arg in value.__args__
+                    )
+                    value = value.__origin__[(*args,)]
                 value = _eval_type(value, base_globals, base_locals)
                 hints[name] = value
History
Date User Action Args
2022-01-25 20:58:47gvanrossumsetrecipients: + gvanrossum, eric.smith, lukasz.langa, levkivskyi, JelleZijlstra, miss-islington, n_rosenstein, BTaskaya, sobolevn, joperez, kj, AlexWaygood
2022-01-25 20:58:47gvanrossumsetmessageid: <1643144327.1.0.689922798222.issue41370@roundup.psfhosted.org>
2022-01-25 20:58:47gvanrossumlinkissue41370 messages
2022-01-25 20:58:47gvanrossumcreate