Debian Codegraph @

tests/data/cases/dummy_implementations.py

raw
1 from typing import NoReturn, Protocol, Union, overload
2
3 class Empty:
4 ...
5
6 def dummy(a): ...
7 async def other(b): ...
8
9
10 @overload
11 def a(arg: int) -> int: ...
12 @overload
13 def a(arg: str) -> str: ...
14 @overload
15 def a(arg: object) -> NoReturn: ...
16 def a(arg: Union[int, str, object]) -> Union[int, str]:
17 if not isinstance(arg, (int, str)):
18 raise TypeError
19 return arg
20
21 class Proto(Protocol):
22 def foo(self, a: int) -> int:
23 ...
24
25 def bar(self, b: str) -> str: ...
26 def baz(self, c: bytes) -> str:
27 ...
28
29
30 def dummy_two():
31 ...
32 @dummy
33 def dummy_three():
34 ...
35
36 def dummy_four():
37 ...
38
39 @overload
40 def b(arg: int) -> int: ...
41
42 @overload
43 def b(arg: str) -> str: ...
44 @overload
45 def b(arg: object) -> NoReturn: ...
46
47 def b(arg: Union[int, str, object]) -> Union[int, str]:
48 if not isinstance(arg, (int, str)):
49 raise TypeError
50 return arg
51
52 def has_comment():
53 ... # still a dummy
54
55 if some_condition:
56 ...
57
58 if already_dummy: ...
59
60 class AsyncCls:
61 async def async_method(self):
62 ...
63
64 async def async_function(self):
65 ...
66
67 @decorated
68 async def async_function(self):
69 ...
70
71 class ClassA:
72 def f(self):
73
74 ...
75
76
77 class ClassB:
78 def f(self):
79
80
81
82
83
84
85
86
87
88 ...
89
90
91 class ClassC:
92 def f(self):
93
94 ...
95 # Comment
96
97
98 class ClassD:
99 def f(self):# Comment 1
100
101 ...# Comment 2
102 # Comment 3
103
104
105 class ClassE:
106 def f(self):
107
108 ...
109 def f2(self):
110 print(10)
111
112
113 class ClassF:
114 def f(self):
115
116 ...# Comment 2
117
118
119 class ClassG:
120 def f(self):#Comment 1
121
122 ...# Comment 2
123
124
125 class ClassH:
126 def f(self):
127 #Comment
128
129 ...
130
131
132 # output
133
134 from typing import NoReturn, Protocol, Union, overload
135
136
137 class Empty: ...
138
139
140 def dummy(a): ...
141 async def other(b): ...
142
143
144 @overload
145 def a(arg: int) -> int: ...
146 @overload
147 def a(arg: str) -> str: ...
148 @overload
149 def a(arg: object) -> NoReturn: ...
150 def a(arg: Union[int, str, object]) -> Union[int, str]:
151 if not isinstance(arg, (int, str)):
152 raise TypeError
153 return arg
154
155
156 class Proto(Protocol):
157 def foo(self, a: int) -> int: ...
158
159 def bar(self, b: str) -> str: ...
160 def baz(self, c: bytes) -> str: ...
161
162
163 def dummy_two(): ...
164 @dummy
165 def dummy_three(): ...
166
167
168 def dummy_four(): ...
169
170
171 @overload
172 def b(arg: int) -> int: ...
173
174
175 @overload
176 def b(arg: str) -> str: ...
177 @overload
178 def b(arg: object) -> NoReturn: ...
179
180
181 def b(arg: Union[int, str, object]) -> Union[int, str]:
182 if not isinstance(arg, (int, str)):
183 raise TypeError
184 return arg
185
186
187 def has_comment(): ... # still a dummy
188
189
190 if some_condition:
191 ...
192
193 if already_dummy:
194 ...
195
196
197 class AsyncCls:
198 async def async_method(self): ...
199
200
201 async def async_function(self): ...
202
203
204 @decorated
205 async def async_function(self): ...
206
207
208 class ClassA:
209 def f(self): ...
210
211
212 class ClassB:
213 def f(self): ...
214
215
216 class ClassC:
217 def f(self):
218
219 ...
220 # Comment
221
222
223 class ClassD:
224 def f(self): # Comment 1
225
226 ... # Comment 2
227 # Comment 3
228
229
230 class ClassE:
231 def f(self): ...
232 def f2(self):
233 print(10)
234
235
236 class ClassF:
237 def f(self): ... # Comment 2
238
239
240 class ClassG:
241 def f(self): # Comment 1
242 ... # Comment 2
243
244
245 class ClassH:
246 def f(self):
247 # Comment
248
249 ...