Skip to content

Commit 42c80d2

Browse files
committed
fix spliting of parameter lines.
if ' : ' is present twice in the line this drops any test after the second ' : ', which happens in some docstring that have the `default : stuff` idiom
1 parent 4e7c5ad commit 42c80d2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

numpydoc/docscrape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _parse_param_list(self, content, single_element_is_type=False):
220220
while not r.eof():
221221
header = r.read().strip()
222222
if ' : ' in header:
223-
arg_name, arg_type = header.split(' : ')[:2]
223+
arg_name, arg_type = header.split(' : ', maxsplit=1)
224224
else:
225225
if single_element_is_type:
226226
arg_name, arg_type = '', header

numpydoc/tests/test_docscrape.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
5656
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional
5757
value drawn from the distribution.
58+
dtype : data type object, optional (default : float)
59+
The type and size of the data to be returned.
5860
list of str
5961
This is not a real return value. It exists to test
6062
anonymous return values.
@@ -205,14 +207,19 @@ def test_returns():
205207
assert arg_type == 'ndarray'
206208
assert desc[0].startswith('The drawn samples')
207209
assert desc[-1].endswith('distribution.')
208-
210+
209211
arg, arg_type, desc = doc['Returns'][1]
212+
assert arg == 'dtype'
213+
assert arg_type == 'data type object, optional (default : float)'
214+
assert desc[0].startswith('The type and size')
215+
216+
arg, arg_type, desc = doc['Returns'][2]
210217
assert arg == ''
211218
assert arg_type == 'list of str'
212219
assert desc[0].startswith('This is not a real')
213220
assert desc[-1].endswith('anonymous return values.')
214221

215-
arg, arg_type, desc = doc['Returns'][2]
222+
arg, arg_type, desc = doc['Returns'][3]
216223
assert arg == ''
217224
assert arg_type == 'no_description'
218225
assert not ''.join(desc).strip()

0 commit comments

Comments
 (0)