This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
I think this is the correct solution -- thanks so much for taking a look at this! I have a couple of points about code readability, and a suggestion about the tests:
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me. I have some ideas about how to clean up the tuple special-casing, but I think that should wait for another PR, as it might not be so backportable.
Sorry @sobolevn and @AlexWaygood, I had trouble checking out the 3.11 backport branch.
Please retry by removing and re-adding the "needs backport to 3.11" label.
Alternatively, you can backport using cherry_picker on the command line. cherry_picker adb0621652f489033b9db8d3949564c9fe545c1d 3.11
Sorry, @sobolevn and @AlexWaygood, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line. cherry_picker adb0621652f489033b9db8d3949564c9fe545c1d 3.10
Sorry @sobolevn and @AlexWaygood, I had trouble checking out the 3.11 backport branch.
Please retry by removing and re-adding the "needs backport to 3.11" label.
Alternatively, you can backport using cherry_picker on the command line. cherry_picker adb0621652f489033b9db8d3949564c9fe545c1d 3.11
…r initial `ParamSpec` substitution (pythonGH-102808)
Previously, this used to fail:
```py
from typing import *
T = TypeVar("T")
P = ParamSpec("P")
class X(Generic[P]):
f: Callable[P, int]
Y = X[[int, T]]
Z = Y[str]
```
(cherry picked from commit adb0621)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
I think backporting this might be quite complex, due to the fact that TypeVarTuple was new in 3.11, meaning a lot of the machinery around substitution changed significantly in 3.11. I glanced at the merge conflicts and they seem nontrivial to resolve.
If you'd like to give it a stab @sobolevn, I'll happily review a backport PR -- but I'm also happy to just leave it unfixed on 3.10.
…ial `ParamSpec` substitution (GH-102808)
Previously, this used to fail:
```py
from typing import *
T = TypeVar("T")
P = ParamSpec("P")
class X(Generic[P]):
f: Callable[P, int]
Y = X[[int, T]]
Z = Y[str]
```
(cherry picked from commit adb0621)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
…r initial `ParamSpec` substitution (python#102808)
Previously, this used to fail:
```py
from typing import *
T = TypeVar("T")
P = ParamSpec("P")
class X(Generic[P]):
f: Callable[P, int]
Y = X[[int, T]]
Z = Y[str]
```
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
warsaw
pushed a commit
to warsaw/cpython
that referenced
this pull request
Apr 11, 2023
…r initial `ParamSpec` substitution (python#102808)
Previously, this used to fail:
```py
from typing import *
T = TypeVar("T")
P = ParamSpec("P")
class X(Generic[P]):
f: Callable[P, int]
Y = X[[int, T]]
Z = Y[str]
```
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've tried to make tests as complete as I can imagine. But, extra cases and suggestions are welcome! ;)
This change has two parts: