Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JukkaL committed May 17, 2024
1 parent dda6804 commit 37f4488
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion test-data/unit/check-python312.test
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ def f[T](x: T) -> T:
reveal_type(h(x)) # N: Revealed type is "T`-1"
return x

[case testPEP695NonLocal]
[case testPEP695NonLocalAndGlobal]
# mypy: enable-incomplete-feature=NewGenericSyntax
def f() -> None:
T = 1
Expand All @@ -1042,6 +1042,19 @@ def g() -> None:
a = 'x' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
return x

x = 1

def h[T](a: T) -> T:
global x
x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
return a

class C[T]:
def m[S](self, a: S) -> S:
global x
x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
return a

[case testPEP695ArgumentDefault]
# mypy: enable-incomplete-feature=NewGenericSyntax
from typing import cast
Expand All @@ -1068,3 +1081,26 @@ def f[T](x: T) -> T:
b = [cast(T, a) for a in [1, 2]]
reveal_type(b) # N: Revealed type is "builtins.list[T`-1]"
return x

[case testPEP695ReuseNameInSameScope]
# mypy: enable-incomplete-feature=NewGenericSyntax

class C[T]:
def m[S](self, x: S, y: T) -> S | T:
return x

def m2[S](self, x: S, y: T) -> S | T:
return x

class D[T]:
pass

def f[T](x: T) -> T:
return x

def g[T](x: T) -> T:
def nested[S](y: S) -> S:
return y
def nested2[S](y: S) -> S:
return y
return x

0 comments on commit 37f4488

Please sign in to comment.