| 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 |
|
| 7 |
default_arg |
| 8 |
|
| 9 |
return a |
| 10 |
|
| 11 |
|
| 12 |
func(1) |
| 13 |
|
| 14 |
func |
| 15 |
|
| 16 |
int(1) + (int(2))+ func('') |
| 17 |
|
| 18 |
|
| 19 |
def func(a): |
| 20 |
|
| 21 |
return a |
| 22 |
|
| 23 |
func(1.0) |
| 24 |
|
| 25 |
|
| 26 |
def func(a): |
| 27 |
|
| 28 |
return a |
| 29 |
|
| 30 |
def func(a): |
| 31 |
|
| 32 |
return a |
| 33 |
str(func(1.0)) |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
def arg(*args): |
| 39 |
|
| 40 |
args |
| 41 |
|
| 42 |
args[0] |
| 43 |
|
| 44 |
arg(1,"") |
| 45 |
|
| 46 |
|
| 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 |
|
| 56 |
return c |
| 57 |
|
| 58 |
|
| 59 |
func("something") |
| 60 |
|
| 61 |
@def_func |
| 62 |
def func(c=1): |
| 63 |
|
| 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 |
|
| 78 |
a |
| 79 |
|
| 80 |
b |
| 81 |
|
| 82 |
func(1.0) |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
import sys as func |
| 87 |
func.sys |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
class A(): |
| 94 |
def __init__(self, a): |
| 95 |
|
| 96 |
a |
| 97 |
|
| 98 |
A("s") |
| 99 |
|
| 100 |
class A(): |
| 101 |
def __init__(self, a): |
| 102 |
|
| 103 |
a |
| 104 |
self.a = a |
| 105 |
|
| 106 |
def test(self, a): |
| 107 |
|
| 108 |
a |
| 109 |
self.c = self.test2() |
| 110 |
|
| 111 |
def test2(self): |
| 112 |
|
| 113 |
return self.a |
| 114 |
|
| 115 |
def test3(self): |
| 116 |
|
| 117 |
self.test2() |
| 118 |
|
| 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 |
|
| 136 |
|
| 137 |
|
| 138 |
def from_comprehension(foo): |
| 139 |
|
| 140 |
return foo |
| 141 |
|
| 142 |
[from_comprehension(1.0) for n in (1,)] |
| 143 |
[from_comprehension(n) for n in (1,)] |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
x_lambda = lambda x: x |
| 151 |
|
| 152 |
x_lambda(1) |
| 153 |
|
| 154 |
class X(): |
| 155 |
|
| 156 |
x_method = lambda self, a: a |
| 157 |
|
| 158 |
|
| 159 |
X().x_method('') |