- Notifications
You must be signed in to change notification settings - Fork263
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
This is related to#1439. Currently, thetyping specs say:
In practice, this restriction seems to only apply to type parameters specified on generictypes, not generic functions/methods. mypy and pyright accepts multiple fromcollections.abcimportCallabledefconcat_args_and_ret[*A,*R](f:Callable[[*A],tuple[*R]],/#`-> tuple[*A, *R]` is rejected, but mypy and pyright can use#`-> tuple[*A, *tuple[*R]]` to solve `R`)->tuple[*A,*tuple[*R]]: ...deff(a:int,b:str,c:bytes,/)->tuple[float,None]: ...reveal_type(concat_args_and_ret(f))# tuple[int, str, bytes, float, None] The ambiguity mentioned in the specs,
|
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 1 comment 1 reply
-
As you point out, the spec allows multiple As for your second question, there are good reasons why multiple The type |
BetaWas this translation helpful?Give feedback.
All reactions
-
The spec as quoted above says "Only a single type variable tuple may appear in a type parameter list", which would seem to include function type parameter lists. Of course, those didn't exist when PEP 646 was written, since before PEP 695 functions didn't have explicit type parameter lists. So I think we should amend that line in the spec to say it applies only to type parameter lists on classes. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2