Debian Codegraph @

test/completion/dynamic_params.py

raw symbols SCIP
1 """
2 This is used for dynamic object completion.
3 Jedi tries to guess param types with a backtracking approach.
4 """
5 def func(a, default_arg=2):
6 #? int()
7 default_arg
8 #? int() str()
9 return a
10
11 #? int()
12 func(1)
13
14 func
15
16 int(1) + (int(2))+ func('')
17
18 # Again the same function, but with another call.
19 def func(a):
20 #? float()
21 return a
22
23 func(1.0)
24
25 # Again the same function, but with no call.
26 def func(a):
27 #?
28 return a
29
30 def func(a):
31 #? float()
32 return a
33 str(func(1.0))
34
35 # -----------------
36 # *args, **args
37 # -----------------
38 def arg(*args):
39 #? tuple()
40 args
41 #? int()
42 args[0]
43
44 arg(1,"")
45 # -----------------
46 # decorators
47 # -----------------
48 def def_func(f):
49 def wrapper(*args, **kwargs):
50 return f(*args, **kwargs)
51 return wrapper
52
53 @def_func
54 def func(c):
55 #? str()
56 return c
57
58 #? str()
59 func("something")
60
61 @def_func
62 def func(c=1):
63 #? float()
64 return c
65
66 func(1.0)
67
68 def tricky_decorator(func):
69 def wrapper(*args):
70 return func(1, *args)
71
72 return wrapper
73
74
75 @tricky_decorator
76 def func(a, b):
77 #? int()
78 a
79 #? float()
80 b
81
82 func(1.0)
83
84 # Needs to be here, because in this case func is an import -> shouldn't lead to
85 # exceptions.
86 import sys as func
87 func.sys
88
89 # -----------------
90 # classes
91 # -----------------
92
93 class A():
94 def __init__(self, a):
95 #? str()
96 a
97
98 A("s")
99
100 class A():
101 def __init__(self, a):
102 #? int()
103 a
104 self.a = a
105
106 def test(self, a):
107 #? float()
108 a
109 self.c = self.test2()
110
111 def test2(self):
112 #? int()
113 return self.a
114
115 def test3(self):
116 #? int()
117 self.test2()
118 #? int()
119 self.c
120
121 A(3).test(2.0)
122 A(3).test2()
123
124
125 def from_class(x):
126 #?
127 x
128
129 from UNDEFINED import from_class
130
131 class Foo(from_class(1),):
132 pass
133
134 # -----------------
135 # comprehensions
136 # -----------------
137
138 def from_comprehension(foo):
139 #? int() float()
140 return foo
141
142 [from_comprehension(1.0) for n in (1,)]
143 [from_comprehension(n) for n in (1,)]
144
145 # -----------------
146 # lambdas
147 # -----------------
148
149 #? int()
150 x_lambda = lambda x: x
151
152 x_lambda(1)
153
154 class X():
155 #? str()
156 x_method = lambda self, a: a
157
158
159 X().x_method('')