Message411674
| 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:47 | gvanrossum | set | recipients: + gvanrossum, eric.smith, lukasz.langa, levkivskyi, JelleZijlstra, miss-islington, n_rosenstein, BTaskaya, sobolevn, joperez, kj, AlexWaygood |
| 2022-01-25 20:58:47 | gvanrossum | set | messageid: <1643144327.1.0.689922798222.issue41370@roundup.psfhosted.org> |
| 2022-01-25 20:58:47 | gvanrossum | link | issue41370 messages |
| 2022-01-25 20:58:47 | gvanrossum | create | |