From e704f8a93bbc9db5f38d6ddc2136839e5567b368 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 18 Apr 2024 09:34:44 -0400 Subject: [PATCH 1/5] FIX: coroutines can have a return statement The value returned by the coroutine is carried on the `StopIteration` Exception that is raised when exhausted. --- numpydoc/docscrape.py | 4 ---- numpydoc/tests/test_docscrape.py | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-) 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..443d961b 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(): From fb17eb189a1a90964742b7fe073ec4a908a7e4de Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 18 Apr 2024 09:49:14 -0400 Subject: [PATCH 2/5] CI: do not test Sphinx 7.3 --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 98b4d79b..e79ced22 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 From 369b4470f2abb0cd85c0f44d200cb14e09bc9651 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 18 Apr 2024 10:12:05 -0400 Subject: [PATCH 3/5] CI: also do not do sphinx 7.3.x on pre-release --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e79ced22..774323b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,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 From 551c8a81c681953abb798ff0b5480aca5d3a32fd Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 18 Apr 2024 10:16:28 -0400 Subject: [PATCH 4/5] CI: also do not use sphinx 7.3 on docs --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) 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 From e613b18d90032a5def3a07e33b136f3ffc0daeac Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 18 Apr 2024 10:17:19 -0400 Subject: [PATCH 5/5] STY: placate linter --- numpydoc/tests/test_docscrape.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numpydoc/tests/test_docscrape.py b/numpydoc/tests/test_docscrape.py index 443d961b..fc6efc0d 100644 --- a/numpydoc/tests/test_docscrape.py +++ b/numpydoc/tests/test_docscrape.py @@ -280,8 +280,8 @@ def test_returnyield(): """ doc = NumpyDocString(doc_text) - assert len(doc['Returns']) == 1 - assert len(doc['Yields']) == 2 + assert len(doc["Returns"]) == 1 + assert len(doc["Yields"]) == 2 def test_section_twice():