Message411670
It was not my intention to sound passive agressive. Thanks for providing the context around the time PEP 585 was discussed.
Frankly, I believe I have explained the problem quite well. But I would like to propose a solution.
I can't judge in what circumstance a `str` would end up in `typing._GenericAlias.__args__` since `typing._GenericAlias.__getitem__()` converts strings to `typing.ForwardRef` using `_type_check()` immediately.
Assuming this is indeed a case to be taken into account, I would propose that `typing.get_type_hint()` implements special treatment for `types.GenericAlias` such that strings in `__args__` are treated as forward references, and keep the old behaviour for `typing._GenericAlias`. Do you see any problems with that?
Of course this would break cases that have come to strictly expect strings in PEP 585 generic `__args__` since the release of Python 3.10 to stay strings, although I cannot come up with an example or think of a usecase myself. |
|
| Date |
User |
Action |
Args |
| 2022-01-25 20:19:15 | n_rosenstein | set | recipients:
+ n_rosenstein, gvanrossum, eric.smith, lukasz.langa, levkivskyi, JelleZijlstra, miss-islington, BTaskaya, sobolevn, joperez, kj, AlexWaygood |
| 2022-01-25 20:19:15 | n_rosenstein | set | messageid: <[email protected]> |
| 2022-01-25 20:19:15 | n_rosenstein | link | issue41370 messages |
| 2022-01-25 20:19:15 | n_rosenstein | create | |
|