Skip to content

Commit e704f8a

Browse files
committed
FIX: coroutines can have a return statement
The value returned by the coroutine is carried on the `StopIteration` Exception that is raised when exhausted.
1 parent defebb1 commit e704f8a

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

numpydoc/docscrape.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,8 @@ def _parse(self):
394394
sections = list(self._read_sections())
395395
section_names = {section for section, content in sections}
396396

397-
has_returns = "Returns" in section_names
398397
has_yields = "Yields" in section_names
399398
# We could do more tests, but we are not. Arbitrarily.
400-
if has_returns and has_yields:
401-
msg = "Docstring contains both a Returns and Yields section."
402-
raise ValueError(msg)
403399
if not has_yields and "Receives" in section_names:
404400
msg = "Docstring contains a Receives section but not Yields."
405401
raise ValueError(msg)

numpydoc/tests/test_docscrape.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ def test_returnyield():
279279
The number of bananas.
280280
281281
"""
282-
assert_raises(ValueError, NumpyDocString, doc_text)
282+
doc = NumpyDocString(doc_text)
283+
assert len(doc['Returns']) == 1
284+
assert len(doc['Yields']) == 2
283285

284286

285287
def test_section_twice():

0 commit comments

Comments
 (0)