Debian Codegraph @

test-data/unit/fine-grained-python312.test

raw
1 [case testPEP695TypeAliasDep]
2 import m
3 def g() -> m.C:
4 return m.f()
5 [file m.py]
6 type C = int
7
8 def f() -> int:
9 pass
10 [file m.py.2]
11 type C = str
12
13 def f() -> int:
14 pass
15 [out]
16 ==
17 main:3: error: Incompatible return value type (got "int", expected "str")
18
19 [case testPEP695ChangeOldStyleToNewStyleTypeAlias]
20 from m import A
21 A()
22
23 [file m.py]
24 A = int
25
26 [file m.py.2]
27 type A = int
28 [typing fixtures/typing-full.pyi]
29 [builtins fixtures/tuple.pyi]
30 [out]
31 ==
32 main:2: error: "TypeAliasType" not callable
33
34 [case testPEP695VarianceChangesDueToDependency]
35 from a import C
36
37 x: C[object] = C[int]()
38
39 [file a.py]
40 from b import A
41
42 class C[T]:
43 def f(self) -> A[T]: ...
44
45 [file b.py]
46 class A[T]:
47 def f(self) -> T: ...
48
49 [file b.py.2]
50 class A[T]:
51 def f(self) -> list[T]: ...
52
53 [out]
54 ==
55 main:3: error: Incompatible types in assignment (expression has type "C[int]", variable has type "C[object]")
56
57 [case testPEP695TypeAliasChangesDueToDependency]
58 from a import A
59 x: A
60 x = 0
61 x = ''
62
63 [file a.py]
64 from b import B
65 type A = B[int, str]
66
67 [file b.py]
68 from typing import Union as B
69
70 [file b.py.2]
71 from builtins import tuple as B
72
73 [builtins fixtures/tuple.pyi]
74 [typing fixtures/typing-full.pyi]
75 [out]
76 ==
77 main:3: error: Incompatible types in assignment (expression has type "int", variable has type "tuple[int, str]")
78 main:4: error: Incompatible types in assignment (expression has type "str", variable has type "tuple[int, str]")
79
80 [case testPEP695NestedGenericClassMethodUpdated]
81 from a import f
82
83 class C:
84 class D[T]:
85 x: T
86 def m(self) -> T:
87 f()
88 return self.x
89
90 [file a.py]
91 def f() -> None: pass
92
93 [file a.py.2]
94 def f(x: int) -> None: pass
95 [out]
96 ==
97 main:7: error: Missing positional argument "x" in call to "f"
98
99 [case testPEP695MultipleNestedGenericClassMethodUpdated]
100 from a import f
101
102 class A:
103 class C:
104 class D[T]:
105 x: T
106 def m(self) -> T:
107 f()
108 return self.x
109
110 [file a.py]
111 def f() -> None: pass
112
113 [file a.py.2]
114 def f(x: int) -> None: pass
115 [out]
116 ==
117 main:8: error: Missing positional argument "x" in call to "f"