[issue40397] Refactor typing._GenericAlias

2021-05-02 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: Looks like there's nothing left to do here. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue40397] Refactor typing._GenericAlias

2020-05-10 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: Thanks Serhyi! I can confirm that the issue I posted is fixed. -- priority: release blocker -> normal ___ Python tracker ___

[issue40397] Refactor typing._GenericAlias

2020-05-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 0122d48681b1df27015cf396559fb283ba364d6d by Serhiy Storchaka in branch 'master': bpo-40397: Fix subscription of nested generic alias without parameters. (GH-20021)

[issue40397] Refactor typing._GenericAlias

2020-05-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Even simpler: Dict[T, List[int]][str]. Dict[T, list[int]][str] also fails. But dict[T, list[int]][str] works as expected (and there are tests). -- ___ Python tracker

[issue40397] Refactor typing._GenericAlias

2020-05-10 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +19332 pull_request: https://github.com/python/cpython/pull/20021 ___ Python tracker ___

[issue40397] Refactor typing._GenericAlias

2020-05-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you Jelle for your report. There is even simpler example: Dict[Tuple[T], List[int]][str] -- ___ Python tracker ___

[issue40397] Refactor typing._GenericAlias

2020-05-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset fcb285609a2e55f2dc63dcfbb32e4e2fddf71546 by Serhiy Storchaka in branch 'master': bpo-40397: Remove __args__ and __parameters__ from _SpecialGenericAlias (GH-19984)

[issue40397] Refactor typing._GenericAlias

2020-05-09 Thread Guido van Rossum
Guido van Rossum added the comment: I think I have a shorter repro, not involving unions: from typing import * T = TypeVar("T") S = TypeVar("S") U = TypeVar("U") class A(Generic[T]): ... class B(Generic[T]): ... class C(Generic[T, S]): ... print(C[A[U], B[int]][str]) Fails in the same place,

[issue40397] Refactor typing._GenericAlias

2020-05-09 Thread Guido van Rossum
Guido van Rossum added the comment: @Serhiy can you look at this? A possible fix might be: diff --git a/Lib/typing.py b/Lib/typing.py index 681ab6d21e..adcef1e82b 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -701,7 +701,8 @@ class _GenericAlias(_BaseGenericAlias, _root=True):

[issue40397] Refactor typing._GenericAlias

2020-05-08 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: The most recent change here caused a regression. The following file: ``` from typing import Generic, TypeVar, Union class CannotTransform(Exception): pass T = TypeVar("T") E = TypeVar("E", bound=Exception) class Ok(Generic[T]): pass class Err(Generic[E]):

[issue40397] Refactor typing._GenericAlias

2020-05-07 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +19300 pull_request: https://github.com/python/cpython/pull/19984 ___ Python tracker ___

[issue40397] Refactor typing._GenericAlias

2020-05-07 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The next PR removes __args__ and __parameters__ from _SpecialGenericAlias. * No existing test is failed. It is an evidence that these attributes are not intended, but a side effect of mixing two different kinds in one class. * get_args() ignores __args__

[issue40397] Refactor typing._GenericAlias

2020-05-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset c1c7d8ead9eb214a6149a43e31a3213c52448877 by Serhiy Storchaka in branch 'master': bpo-40397: Refactor typing._GenericAlias (GH-19719) https://github.com/python/cpython/commit/c1c7d8ead9eb214a6149a43e31a3213c52448877 --

[issue40397] Refactor typing._GenericAlias

2020-04-26 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +19040 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19719 ___ Python tracker

[issue40397] Refactor typing._GenericAlias

2020-04-26 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : typing._GenericAlias represents two different types: user defined (like List[int]) and special (like List). They have different behavior, and common methods contain special cases. The proposed PR rewrites the implementation in more object-oriented