Debian Codegraph @

tests/data/cases/type_param_defaults.py

raw
1 # flags: --minimum-version=3.13
2
3 type A[T=int] = float
4 type B[*P=int] = float
5 type C[*Ts=int] = float
6 type D[*Ts=*int] = float
7 type D[something_that_is_very_very_very_long=something_that_is_very_very_very_long] = float
8 type D[*something_that_is_very_very_very_long=*something_that_is_very_very_very_long] = float
9 type something_that_is_long[something_that_is_long=something_that_is_long] = something_that_is_long
10
11 def simple[T=something_that_is_long](short1: int, short2: str, short3: bytes) -> float:
12 pass
13
14 def longer[something_that_is_long=something_that_is_long](something_that_is_long: something_that_is_long) -> something_that_is_long:
15 pass
16
17 def trailing_comma1[T=int,](a: str):
18 pass
19
20 def trailing_comma2[T=int](a: str,):
21 pass
22
23 def weird_syntax[T=lambda: 42, **P=lambda: 43, *Ts=lambda: 44](): pass
24
25 # output
26
27 type A[T = int] = float
28 type B[*P = int] = float
29 type C[*Ts = int] = float
30 type D[*Ts = *int] = float
31 type D[
32 something_that_is_very_very_very_long = something_that_is_very_very_very_long
33 ] = float
34 type D[
35 *something_that_is_very_very_very_long = *something_that_is_very_very_very_long
36 ] = float
37 type something_that_is_long[
38 something_that_is_long = something_that_is_long
39 ] = something_that_is_long
40
41
42 def simple[T = something_that_is_long](
43 short1: int, short2: str, short3: bytes
44 ) -> float:
45 pass
46
47
48 def longer[something_that_is_long = something_that_is_long](
49 something_that_is_long: something_that_is_long,
50 ) -> something_that_is_long:
51 pass
52
53
54 def trailing_comma1[
55 T = int,
56 ](
57 a: str,
58 ):
59 pass
60
61
62 def trailing_comma2[T = int](
63 a: str,
64 ):
65 pass
66
67
68 def weird_syntax[T = lambda: 42, **P = lambda: 43, *Ts = lambda: 44]():
69 pass