blob: 2cb2148a66fef1ae2fb0183ccf6918797a9e7c9c [file] [log] [blame] [edit]
[case testPEP695TypeAliasDep]
import m
def g() -> m.C:
return m.f()
[file m.py]
type C = int
def f() -> int:
pass
[file m.py.2]
type C = str
def f() -> int:
pass
[out]
==
main:3: error: Incompatible return value type (got "int", expected "str")
[case testPEP695ChangeOldStyleToNewStyleTypeAlias]
from m import A
A()
[file m.py]
A = int
[file m.py.2]
type A = int
[typing fixtures/typing-full.pyi]
[builtins fixtures/tuple.pyi]
[out]
==
main:2: error: "TypeAliasType" not callable
[case testPEP695VarianceChangesDueToDependency]
from a import C
x: C[object] = C[int]()
[file a.py]
from b import A
class C[T]:
def f(self) -> A[T]: ...
[file b.py]
class A[T]:
def f(self) -> T: ...
[file b.py.2]
class A[T]:
def f(self) -> list[T]: ...
[out]
==
main:3: error: Incompatible types in assignment (expression has type "C[int]", variable has type "C[object]")
[case testPEP695TypeAliasChangesDueToDependency]
from a import A
x: A
x = 0
x = ''
[file a.py]
from b import B
type A = B[int, str]
[file b.py]
from typing import Union as B
[file b.py.2]
from builtins import tuple as B
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]
[out]
==
main:3: error: Incompatible types in assignment (expression has type "int", variable has type "Tuple[int, str]")
main:4: error: Incompatible types in assignment (expression has type "str", variable has type "Tuple[int, str]")
[case testPEP695NestedGenericClassMethodUpdated]
from a import f
class C:
class D[T]:
x: T
def m(self) -> T:
f()
return self.x
[file a.py]
def f() -> None: pass
[file a.py.2]
def f(x: int) -> None: pass
[out]
==
main:7: error: Missing positional argument "x" in call to "f"
[case testPEP695MultipleNestedGenericClassMethodUpdated]
from a import f
class A:
class C:
class D[T]:
x: T
def m(self) -> T:
f()
return self.x
[file a.py]
def f() -> None: pass
[file a.py.2]
def f(x: int) -> None: pass
[out]
==
main:8: error: Missing positional argument "x" in call to "f"