Skip to content

Commit 9e5ffb2

Browse files
authored
Fix default parameter problem (#49)
1 parent 07635ee commit 9e5ffb2

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

CHANGES.rst

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Version 0.4.0
2+
-------------
3+
Released on May 6th 2018
4+
5+
- Bug fix
6+
7+
- Default parameter problem
8+
9+
see https://github.com/heavenshell/vim-pydocstring/issues/46
10+
111
Version 0.3.0
212
-------------
313
Released on Dec 10th 2017

autoload/pydocstring.vim

+3-1
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,10 @@ function! s:parse_func(type, line)
153153
let header = substitute(a:line, '\s\|(.*\|:', '', 'g')
154154

155155
let args_str = substitute(a:line, '\s\|.*(\|).*', '', 'g')
156-
if args_str =~ ':'
156+
if args_str =~ ':' && args_str =~ '['
157157
let args = s:parse_args(args_str)
158+
elseif args_str =~ ':'
159+
let args = split(args_str, ',')
158160
else
159161
" No typed args.
160162
let args = split(args_str, ',')

doc/pydocstring.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*pydocstring.txt* Generate Python docstring to your Python code.
22

3-
Version: 0.3.0
3+
Version: 0.4.0
44
Author: Shinya Ohynagi <[email protected]>
55
Repository: http://github.com/heavenshell/vim-pydocstring/
66
License: BSD, see LICENSE for more details.

test/type-hint.vader

+36
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,39 @@ Expect python:
247247
:type arg2: Callable[List[str, str], str, int]
248248
"""
249249
pass
250+
251+
Given python (def first has type, the rest is not):
252+
def foo(a: int, b, c) -> int:
253+
pass
254+
255+
Execute:
256+
Pydocstring
257+
258+
Expect python:
259+
def foo(a: int, b, c) -> int:
260+
"""foo
261+
262+
:param a:
263+
:type a: int
264+
:param b:
265+
:param c:
266+
:rtype: int
267+
"""
268+
pass
269+
270+
Given python (keyword args):
271+
def foo(a, b: str = None):
272+
pass
273+
274+
Execute:
275+
Pydocstring
276+
277+
Expect python:
278+
def foo(a, b: str = None):
279+
"""foo
280+
281+
:param a:
282+
:param b:
283+
:type b: str
284+
"""
285+
pass

0 commit comments

Comments
 (0)