Message403596
@Guido,
I hope I didn't misunderstand you, but to clarify, what OP is asking is an alternative way to construct types.UnionType objects and write:
types.UnionType[int, str]
like how we used to write before 3.10:
typing.Union[int, str]
I don't know why we need this. We can write `int | str`. The reason for PEP 604 in the first place was to avoid the subscript syntax and use `|` since it's cleaner. OP's use case is for reconstructing types.UnionType objects easily, but `functools.reduce(operator.or_, args)` works.
Re: TypeVar subscription; PEP 604 syntax already supports that. We used to implement that in C. After Serhiy's Great Cleanup, a bitwise OR with a TypeVar automatically converts types.UnionType to typing.Union. So all the TypeVar support is now done in Python.
>>> type(int | str)
<class 'types.UnionType'>
>>> (int | str | T)[dict]
typing.Union[int, str, dict] |
|
Date |
User |
Action |
Args |
2021-10-10 15:38:27 | kj | set | recipients:
+ kj, gvanrossum, serhiy.storchaka, joperez |
2021-10-10 15:38:27 | kj | set | messageid: <1633880307.4.0.863094968996.issue45418@roundup.psfhosted.org> |
2021-10-10 15:38:27 | kj | link | issue45418 messages |
2021-10-10 15:38:27 | kj | create | |
|