@@ -52,15 +52,20 @@ Groups:
5252 " Split python argument string ARG-STRING.
5353
5454The 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 ))))
6469
6570(defun python-args-to-docstring ()
6671 " Return docstring format for the python arguments in yas-text."
@@ -108,6 +113,14 @@ default values."
108113 '(" foobar" nil nil )))
109114 ))
110115
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+
111124; ; For manual testing and development:
112125
113126; ; (setq yas-text "foo=3, bar: int = 2, baz: Optional[MyType], foobar")
0 commit comments