Debian Codegraph @

test/completion/named_param.py

raw symbols SCIP
1 """
2 Named Params:
3 >>> def a(abc): pass
4 ...
5 >>> a(abc=3) # <- this stuff (abc)
6 """
7
8 def a(abc):
9 pass
10
11 #? 5 ['abc=']
12 a(abc)
13
14
15 def a(*some_args, **some_kwargs):
16 pass
17
18 #? 11 []
19 a(some_args)
20
21 #? 13 []
22 a(some_kwargs)
23
24 def multiple(foo, bar):
25 pass
26
27 #? 17 ['bar=']
28 multiple(foo, bar)
29
30 #? ['bar=']
31 multiple(foo, bar
32
33 my_lambda = lambda lambda_param: lambda_param + 1
34 #? 22 ['lambda_param=']
35 my_lambda(lambda_param)
36
37 # __call__ / __init__
38 class Test(object):
39 def __init__(self, hello_other):
40 pass
41
42 def __call__(self, hello):
43 pass
44
45 def test(self, blub):
46 pass
47
48 #? 10 ['hello_other=']
49 Test(hello=)
50 #? 12 ['hello=']
51 Test()(hello=)
52 #? 11 []
53 Test()(self=)
54 #? 16 []
55 Test().test(self=)
56 #? 16 ['blub=']
57 Test().test(blub=)
58
59 # builtins
60
61 #? 12 []
62 any(iterable=)
63
64
65 def foo(xyz):
66 pass
67
68 #? 7 ['xyz=']
69 @foo(xy)
70 def x(): pass
71
72 #? 7 ['xyz=']
73 foo(xyz)
74 # No completion should be possible if it's not a simple name
75 #? 17 []
76 x = " "; foo(x.xyz)
77 #? 17 []
78 x = " "; foo([xyz)
79 #? 20 []
80 x = " "; foo(z[f,xyz)
81 #? 18 []
82 x = " "; foo(z[xyz)
83 #? 20 []
84 x = " "; foo(xyz[xyz)
85 #? 20 []
86 x = " "; foo(xyz[(xyz)
87
88 #? 8 ['xyz=']
89 @foo(xyz)
90 def x(): pass
91
92 @str
93 #? 8 ['xyz=']
94 @foo(xyz)
95 def x(): pass
96
97 # -----------------
98 # Only keyword arguments are valid
99 # -----------------
100
101 def x(bam, *, bar, baz):
102 pass
103 def y(bam, *bal, bar, baz, **bag):
104 pass
105 def z(bam, bar=2, *, bas=1):
106 pass
107
108 #? 7 ['bar=', 'baz=']
109 x(1, ba)
110
111 # python >= 3.11
112
113 #? 14 ['baz=']
114 x(1, bar=2, ba)
115 #? 7 ['bar=', 'baz=']
116 x(1, ba, baz=3)
117 #? 14 ['baz=']
118 x(1, bar=2, baz=3)
119 #? 7 ['BaseException', 'BaseExceptionGroup']
120 x(basee)
121 #? 22 ['bar=', 'baz=']
122 x(1, 2, 3, 4, 5, 6, bar=2)
123
124 #? 14 ['baz=']
125 y(1, bar=2, ba)
126 #? 7 ['bar=', 'BaseException', 'BaseExceptionGroup', 'baz=']
127 y(1, ba, baz=3)
128 #? 14 ['baz=']
129 y(1, bar=2, baz=3)
130 #? 7 ['BaseException', 'BaseExceptionGroup']
131 y(basee)
132 #? 22 ['bar=', 'BaseException', 'BaseExceptionGroup', 'baz=']
133 y(1, 2, 3, 4, 5, 6, bar=2)
134
135 #? 11 ['bar=', 'bas=']
136 z(bam=1, bar=2, bas=3)
137 #? 8 ['BaseException', 'BaseExceptionGroup', 'bas=']
138 z(1, bas=2)
139 #? 12 ['BaseException', 'BaseExceptionGroup']
140 z(1, bas=bas)
141
142 #? 19 ['dict']
143 z(1, bas=bas, **dic)
144 #? 18 ['dict']
145 z(1, bas=bas, *dic)