Skip to content

[PEP 695] Allow Self return types with contravariance #17786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
New syntax does not need to be enabled with a flag
  • Loading branch information
JukkaL committed Sep 20, 2024
commit ae0876380cf16463c283e9a269f23776cc6c1fb3
2 changes: 0 additions & 2 deletions test-data/unit/check-python312.test
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ inv3_2: Invariant3[int] = Invariant3[float](1) # E: Incompatible types in assig
[builtins fixtures/property.pyi]

[case testPEP695InferVarianceWithInheritedSelf]
# flags: --enable-incomplete-feature=NewGenericSyntax
from typing import overload, Self, TypeVar, Generic

T = TypeVar("T")
Expand All @@ -413,7 +412,6 @@ a3: D[int, int] = D[object, object]() # E: Incompatible types in assignment (ex
a4: D[object, int] = D[int, object]() # E: Incompatible types in assignment (expression has type "D[int, object]", variable has type "D[object, int]")

[case testPEP695InferVarianceWithReturnSelf]
# flags: --enable-incomplete-feature=NewGenericSyntax
from typing import Self, overload

class Cov[T]:
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/pythoneval.test
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@ type L1 = Never
type L2 = list[Never]

[case testPEP695VarianceInferenceSpecialCaseWithTypeshed]
# flags: --python-version=3.12 --enable-incomplete-feature=NewGenericSyntax
# flags: --python-version=3.12
class C1[T1, T2](list[T1]):
def m(self, a: T2) -> None: ...

Expand Down
Loading