[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2022-03-12 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: PR 31143 simplified some code without changing the common API: Objects/genericaliasobject.c | 46 ++ 1 file changed, 14 insertions(+), 32 deletions(-) Lib/_collections_abc.py | 63

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2022-03-11 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset b6a5d8590c4bfe4553d796b36af03bda8c0d5af5 by Serhiy Storchaka in branch 'main': bpo-44796: Unify TypeVar and ParamSpec substitution (GH-31143) https://github.com/python/cpython/commit/b6a5d8590c4bfe4553d796b36af03bda8c0d5af5 --

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2022-02-06 Thread Guido van Rossum
Guido van Rossum added the comment: Super subtle stuff. Tonight I do not have time to really dive into this, but I think Serhiy is on to something. KJ or Jelle, do you have the guts to dive in here? -- ___ Python tracker

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2022-02-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I have created an alternative PR 31143 which adds special method __typing_subst__ in TypeVar and ParamSpec instead of __parameters__ and __getitem__. It has almost the same effect except making TypeVar and ParamSpec and subscriptable. The Python code in

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2022-02-05 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +29321 pull_request: https://github.com/python/cpython/pull/31143 ___ Python tracker ___

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2022-02-03 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: I'd also be wary about making changes that introduce additional runtime checks. As we've seen with the PEP 612 and 646 implementations, those can impede future iteration on typing. -- ___ Python tracker

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2022-02-03 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +AlexWaygood, sobolevn ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2022-02-03 Thread Guido van Rossum
Guido van Rossum added the comment: I don't think that changing list[None] to list[NoneType] in the output is an improvement. I do appreciate the reduction in C code though! -- ___ Python tracker

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2022-02-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It does not have a use case of T[int] in mind. It is an implementation detail which simplifies the code, makes runtime checks more strict and makes types.GenericAlias more similar to typing._GenericAlias. For example, currently: >>> A = List[T] >>> B =

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2022-01-24 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: The linked PR makes `T = TypeVar("T"); T[int]` work. That's not currently meaningful syntax to the type checker, but we may want it in the future for higher-kinded types. I would rather not make this change without a clear static typing use case in mind.

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2021-07-31 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- Removed message: https://bugs.python.org/msg398655 ___ Python tracker ___ ___ Python-bugs-list

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2021-07-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: There is also similar bug in Generic: >>> from typing import * >>> T = TypeVar("T") >>> P = ParamSpec("P") >>> class X(Generic[T, P]): ... f: Callable[P, int] ... x: T ... >>> P_2 = ParamSpec("P_2") >>> X[int, P_2, str] __main__.X[int, ~P_2]

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2021-07-31 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +26025 stage: -> patch review pull_request: https://github.com/python/cpython/pull/27511 ___ Python tracker

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2021-07-31 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- dependencies: +Merge tests for typing.Callable and collection.abc.Callable ___ Python tracker ___

[issue44796] Add __parameters__ and __getitem__ in TypeVar and ParamSpec

2021-07-31 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : Adding __parameters__ and __getitem__ in TypeVar and ParamSpec allows to generalize and simplify the code (especially the C code) and allows to add more runtime checks. It may open ways for further simplification. Unfortunately it is not compatible with