From ef0a8b5425715205aaf00dfd42228515896c4452 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 20 Apr 2024 15:31:41 -0400 Subject: [PATCH] FIX: coroutines can have a return statement (#542) * FIX: coroutines can have a return statement The value returned by the coroutine is carried on the `StopIteration` Exception that is raised when exhausted. * CI: do not test Sphinx 7.3 * CI: also do not do sphinx 7.3.x on pre-release * CI: also do not use sphinx 7.3 on docs * STY: placate linter --- .circleci/config.yml | 1 + .github/workflows/test.yml | 6 +++++- numpydoc/docscrape.py | 4 ---- numpydoc/tests/test_docscrape.py | 4 +++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 66a60c8d..a67976c0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,6 +21,7 @@ jobs: source venv/bin/activate python -m pip install --upgrade pip wheel setuptools python -m pip install --upgrade -r requirements/doc.txt + python -m pip install 'sphinx!=7.3.*' python -m pip list - save_cache: key: pip-cache diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 98b4d79b..774323b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,10 @@ jobs: os: [Ubuntu] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] sphinx-version: - ["sphinx==6.0", "sphinx==6.2", "sphinx==7.0", "sphinx>=7.2"] + ["sphinx==6.0", "sphinx==6.2", "sphinx==7.0", "'sphinx>=7.2,<7.3'"] + exclude: + - python-version: "3.8" + sphinx-version: "'sphinx>=7.2,<7.3'" steps: - uses: actions/checkout@v4 @@ -84,6 +87,7 @@ jobs: python -m pip install --upgrade pip wheel setuptools python -m pip install --pre -r requirements/test.txt -r requirements/doc.txt python -m pip install codecov + python -m pip install 'sphinx!=7.3.*' python -m pip list - name: Install diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index fb3a0b63..8adcf869 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -394,12 +394,8 @@ def _parse(self): sections = list(self._read_sections()) section_names = {section for section, content in sections} - has_returns = "Returns" in section_names has_yields = "Yields" in section_names # We could do more tests, but we are not. Arbitrarily. - if has_returns and has_yields: - msg = "Docstring contains both a Returns and Yields section." - raise ValueError(msg) if not has_yields and "Receives" in section_names: msg = "Docstring contains a Receives section but not Yields." raise ValueError(msg) diff --git a/numpydoc/tests/test_docscrape.py b/numpydoc/tests/test_docscrape.py index 8bbcdc53..fc6efc0d 100644 --- a/numpydoc/tests/test_docscrape.py +++ b/numpydoc/tests/test_docscrape.py @@ -279,7 +279,9 @@ def test_returnyield(): The number of bananas. """ - assert_raises(ValueError, NumpyDocString, doc_text) + doc = NumpyDocString(doc_text) + assert len(doc["Returns"]) == 1 + assert len(doc["Yields"]) == 2 def test_section_twice():