File: arguments.py

package info (click to toggle)
python-jedi 0.10.0~git1%2Bf05c071-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,064 kB
  • ctags: 3,014
  • sloc: python: 16,997; makefile: 149; ansic: 13
file content (73 lines) | stat: -rw-r--r-- 1,150 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -----------------
# normal arguments (no keywords)
# -----------------


def simple(a):
    return a

simple(1)
#! 6 type-error-too-few-arguments
simple()
#! 10 type-error-too-many-arguments
simple(1, 2)


#! 10 type-error-too-many-arguments
simple(1, 2, 3)

# -----------------
# keyword arguments
# -----------------

simple(a=1)
#! 7 type-error-keyword-argument
simple(b=1)
#! 10 type-error-too-many-arguments
simple(1, a=1)


def two_params(x, y):
    return y


two_params(y=2, x=1)
two_params(1, y=2)

#! 11 type-error-multiple-values
two_params(1, x=2)
#! 17 type-error-too-many-arguments
two_params(1, 2, y=3)

# -----------------
# default arguments
# -----------------

def default(x, y=1, z=2):
    return x

#! 7 type-error-too-few-arguments
default()
default(1)
default(1, 2)
default(1, 2, 3)
#! 17 type-error-too-many-arguments
default(1, 2, 3, 4)

default(x=1)

# -----------------
# class arguments
# -----------------

class Instance():
    def __init__(self, foo):
        self.foo = foo

Instance(1).foo
Instance(foo=1).foo

#! 12 type-error-too-many-arguments
Instance(1, 2).foo
#! 8 type-error-too-few-arguments
Instance().foo