[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-26 Thread Łukasz Langa
Łukasz Langa added the comment: New changeset 4a5457d5d48e6563ec481daad245ff3d6ef13503 by Miss Islington (bot) in branch '3.10': bpo-44490: Add 'Whats New' docs regarding types.Union changes (GH-27215) (GH-27368)

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-26 Thread miss-islington
Change by miss-islington : -- pull_requests: +25906 pull_request: https://github.com/python/cpython/pull/27368 ___ Python tracker ___

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-26 Thread Łukasz Langa
Łukasz Langa added the comment: New changeset 6c1b57d958e2b0d5bcf0f2315b5044838e11638f by Yurii Karabas in branch 'main': bpo-44490: Add 'Whats New' docs regarding types.Union changes (GH-27215) https://github.com/python/cpython/commit/6c1b57d958e2b0d5bcf0f2315b5044838e11638f --

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-19 Thread Guido van Rossum
Guido van Rossum added the comment: New changeset a2721649598eb715304a1ac8678a409585f73b27 by Ken Jin in branch '3.10': bpo-44490: Improve typing module compatibility with types.Union (GH-27048) (#27222) https://github.com/python/cpython/commit/a2721649598eb715304a1ac8678a409585f73b27

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-18 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +25763 pull_request: https://github.com/python/cpython/pull/27222 ___ Python tracker ___ ___

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-17 Thread Ken Jin
Change by Ken Jin : -- pull_requests: -25752 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-17 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 9.0 -> 10.0 pull_requests: +25761 pull_request: https://github.com/python/cpython/pull/27220 ___ Python tracker

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 2d055ce13250a4074f66a945381a149a3cf8c46f by Serhiy Storchaka in branch '3.10': [3.10] bpo-44490: Add __parameters__ and __getitem__ to types.Union (GH-26980) (GH-27207)

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-17 Thread Yurii Karabas
Change by Yurii Karabas <1998uri...@gmail.com>: -- pull_requests: +25753 pull_request: https://github.com/python/cpython/pull/27215 ___ Python tracker ___

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-17 Thread Yurii Karabas
Change by Yurii Karabas <1998uri...@gmail.com>: -- pull_requests: +25752 pull_request: https://github.com/python/cpython/pull/27214 ___ Python tracker ___

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-17 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- nosy: +serhiy.storchaka nosy_count: 8.0 -> 9.0 pull_requests: +25743 pull_request: https://github.com/python/cpython/pull/27207 ___ Python tracker

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-16 Thread Ken Jin
Change by Ken Jin : -- pull_requests: +25737 pull_request: https://github.com/python/cpython/pull/27203 ___ Python tracker ___ ___

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-16 Thread Guido van Rossum
Change by Guido van Rossum : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed type: -> enhancement ___ Python tracker ___

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-16 Thread Guido van Rossum
Guido van Rossum added the comment: New changeset bf89ff96e6ba21bb52b8597b5e51e8ffc57e6589 by Yurii Karabas in branch 'main': bpo-44490: Improve typing module compatibility with types.Union (GH-27048) https://github.com/python/cpython/commit/bf89ff96e6ba21bb52b8597b5e51e8ffc57e6589

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-06 Thread Yurii Karabas
Change by Yurii Karabas <1998uri...@gmail.com>: -- pull_requests: +25604 pull_request: https://github.com/python/cpython/pull/27048 ___ Python tracker ___

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-06 Thread Guido van Rossum
Guido van Rossum added the comment: New changeset c45fa1a5d9b419cf13ad4b5a7cb453956495b83e by Yurii Karabas in branch 'main': bpo-44490: Add __parameters__ and __getitem__ to types.Union (GH-26980) https://github.com/python/cpython/commit/c45fa1a5d9b419cf13ad4b5a7cb453956495b83e --

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-03 Thread ROpdebee
ROpdebee added the comment: It also lacks the __module__ attribute, causing it to be unusable in PEP 593 typing.Annotated types: from typing import Annotated x: Annotated[int | str, 'test'] Traceback (most recent call last): File "", line 1, in File

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-07-01 Thread Yurii Karabas
Change by Yurii Karabas <1998uri...@gmail.com>: -- keywords: +patch pull_requests: +25542 stage: -> patch review pull_request: https://github.com/python/cpython/pull/26980 ___ Python tracker

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-30 Thread Yurii Karabas
Yurii Karabas <1998uri...@gmail.com> added the comment: @Ken I will pick up this issue, thanks for asking. -- ___ Python tracker ___

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-29 Thread Ken Jin
Ken Jin added the comment: I don't think we need the types.GenericAlias(int | list[T], str) workaround. GenericAlias already has code for extracting __parameters__ and implementing __getitem__. Someone would need to refactor and reuse them for Union too. That should be enough to trick

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-29 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: I'd also be OK with returning a `types.GenericAlias(int | list[T], str)`, which might be simpler. It doesn't matter for static type checkers, and runtime type checkers can extract what they need anyway. -- ___

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-29 Thread Guido van Rossum
Guido van Rossum added the comment: So I guess to expand on Jelle's example, Alias[str] should return (int | list[str]), right? That makes sense since that's how Union works. -- ___ Python tracker

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-29 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: Mypy is definitely not going to support direct access to `__parameters__`; what Guido is referring to is whether usage of types.Union that would require `__parameters__` at runtime is accepted by mypy. For example, this: from typing import TypeVar T =

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-29 Thread Jack DeVries
Jack DeVries added the comment: mypy does not support __parameters__: (venv) ➜ cpython git:(main) cat repro.py from typing import TypeVar T = TypeVar('T') (int | list[T]).__parameters__ (venv) ➜ cpython git:(main) mypy --version mypy

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-29 Thread Guido van Rossum
Guido van Rossum added the comment: I intended for someone to write some test programs and report back here what mypy actually supports and what it doesn't. -- ___ Python tracker

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-29 Thread Ken Jin
Ken Jin added the comment: Yurii, thanks for the offer. We only need to implement __getitem__ if union supports TypeVars. Which means __parameters__ need to be implemented too (or at least a private internal implementation of it). I interpreted Guido's message above as to wait and see if

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-29 Thread Yurii Karabas
Yurii Karabas <1998uri...@gmail.com> added the comment: Should `__getitem__` be implemented for `types.Union`? I can implement it if no one is working on it. P.S. mypy currently does not support it: ``` Value of type "types.Union" is not indexable ``` -- nosy: +uriyyo

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-23 Thread Brandt Bucher
Change by Brandt Bucher : -- nosy: +brandtbucher ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-22 Thread Guido van Rossum
Guido van Rossum added the comment: Let's first see whether the type (int | list[T]) is accepted by static checkers. IMO introspecting unions should be done by looking at __args__, nothing more. -- ___ Python tracker

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-22 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: I agree that this is a bug. `types.Union` is also missing a __getitem__ implementation. And `typing.Union` supports pickling while `types.Union` doesn't: >>> pickle.loads(pickle.dumps(int | str)) Traceback (most recent call last): File "", line 1, in

[issue44490] PEP 604 Union (int | str) doesn't have __parameters__

2021-06-22 Thread Ken Jin
New submission from Ken Jin : Recently I noticed that the new PEP 604 Union type doesn't collect type variables: from typing import TypeVar T = TypeVar('T') (int | list[T]).__parameters__ Traceback (most recent call last): File "", line 1, in AttributeError: 'types.Union' object has no