| 1 | # ----------------- |
| 2 | # normal arguments (no keywords) |
| 3 | # ----------------- |
| 4 | |
| 5 | |
| 6 | def simple(a): |
| 7 | return a |
| 8 | |
| 9 | simple(1) |
| 10 | #! 6 type-error-too-few-arguments |
| 11 | simple() |
| 12 | #! 10 type-error-too-many-arguments |
| 13 | simple(1, 2) |
| 14 | |
| 15 | |
| 16 | #! 10 type-error-too-many-arguments |
| 17 | simple(1, 2, 3) |
| 18 | |
| 19 | # ----------------- |
| 20 | # keyword arguments |
| 21 | # ----------------- |
| 22 | |
| 23 | simple(a=1) |
| 24 | #! 7 type-error-keyword-argument |
| 25 | simple(b=1) |
| 26 | #! 10 type-error-too-many-arguments |
| 27 | simple(1, a=1) |
| 28 | |
| 29 | |
| 30 | def two_params(x, y): |
| 31 | return y |
| 32 | |
| 33 | |
| 34 | two_params(y=2, x=1) |
| 35 | two_params(1, y=2) |
| 36 | |
| 37 | #! 11 type-error-multiple-values |
| 38 | two_params(1, x=2) |
| 39 | #! 17 type-error-too-many-arguments |
| 40 | two_params(1, 2, y=3) |
| 41 | |
| 42 | # ----------------- |
| 43 | # default arguments |
| 44 | # ----------------- |
| 45 | |
| 46 | def default(x, y=1, z=2): |
| 47 | return x |
| 48 | |
| 49 | #! 7 type-error-too-few-arguments |
| 50 | default() |
| 51 | default(1) |
| 52 | default(1, 2) |
| 53 | default(1, 2, 3) |
| 54 | #! 17 type-error-too-many-arguments |
| 55 | default(1, 2, 3, 4) |
| 56 | |
| 57 | default(x=1) |
| 58 | |
| 59 | # ----------------- |
| 60 | # class arguments |
| 61 | # ----------------- |
| 62 | |
| 63 | class Instance(): |
| 64 | def __init__(self, foo): |
| 65 | self.foo = foo |
| 66 | |
| 67 | Instance(1).foo |
| 68 | Instance(foo=1).foo |
| 69 | |
| 70 | #! 12 type-error-too-many-arguments |
| 71 | Instance(1, 2).foo |
| 72 | #! 8 type-error-too-few-arguments |
| 73 | Instance().foo |