@@ -52,15 +52,20 @@ Groups:
52
52
" Split python argument string ARG-STRING.
53
53
54
54
The result is a list ((name, type, default), ...) of argument names, types and
55
- default values."
56
- (mapcar (lambda (x ) ; organize output
57
- (when (string-match python-split-arg-regex x)
58
- (list
59
- (match-string-no-properties 1 x) ; name
60
- (match-string-no-properties 3 x) ; type
61
- (match-string-no-properties 5 x) ; default
62
- )))
63
- (split-string arg-string python-split-arg-separator t )))
55
+ default values. An argument named `self` is omitted."
56
+ (remove
57
+ nil
58
+ (mapcar (lambda (x ) ; organize output
59
+ (when (and
60
+ (not (equal " self" x))
61
+ (string-match python-split-arg-regex x)
62
+ )
63
+ (list
64
+ (match-string-no-properties 1 x) ; name
65
+ (match-string-no-properties 3 x) ; type
66
+ (match-string-no-properties 5 x) ; default
67
+ )))
68
+ (split-string arg-string python-split-arg-separator t ))))
64
69
65
70
(defun python-args-to-docstring ()
66
71
" Return docstring format for the python arguments in yas-text."
@@ -108,6 +113,14 @@ default values."
108
113
'(" foobar" nil nil )))
109
114
))
110
115
116
+ (ert-deftest test-argument-self ()
117
+ " If an argument is called `self`, it must be omitted"
118
+ (should (equal
119
+ (python-split-args " self, _foo=\" this\" " )
120
+ (list '(" _foo" nil " \" this\" " )
121
+ ))
122
+ ))
123
+
111
124
; ; For manual testing and development:
112
125
113
126
; ; (setq yas-text "foo=3, bar: int = 2, baz: Optional[MyType], foobar")
0 commit comments