Skip to content

Commit d823f99

Browse files
authored
Resolve issue 305 (#307)
Resolves #305
1 parent fb30e40 commit d823f99

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
- Fix a `Field list ends without a blank line` warning (issue 305).
6+
37
## 1.21.5
48

59
- More robust determination of rtype location / fix issue 302

src/sphinx_autodoc_typehints/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,9 @@ def _inject_rtype(
758758

759759
formatted_annotation = format_annotation(type_hints["return"], app.config)
760760

761+
if r.found_param and insert_index < len(lines) and lines[insert_index].strip() != "":
762+
insert_index -= 1
763+
761764
if insert_index == len(lines) and not r.found_param:
762765
# ensure that :rtype: doesn't get joined with a paragraph of text
763766
lines.append("")

tests/test_integration.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,41 @@ def func_with_definition_list() -> int:
874874
# See https://github.com/tox-dev/sphinx-autodoc-typehints/issues/302
875875

876876

877+
@expected(
878+
"""\
879+
mod.decorator_2(f)
880+
881+
Run the decorated function with *asyncio.run*.
882+
883+
Parameters:
884+
**f** ("Any") -- The function to wrap.
885+
886+
Return type:
887+
"Any"
888+
889+
-[ Examples ]-
890+
891+
A
892+
"""
893+
)
894+
def decorator_2(f: Any) -> Any:
895+
"""Run the decorated function with `asyncio.run`.
896+
897+
Parameters
898+
----------
899+
f
900+
The function to wrap.
901+
902+
Examples
903+
--------
904+
905+
.. code-block:: python
906+
907+
A
908+
"""
909+
f
910+
911+
877912
AUTO_FUNCTION = ".. autofunction:: mod.{}"
878913
AUTO_CLASS = """\
879914
.. autoclass:: mod.{}
@@ -914,5 +949,5 @@ def test_integration(app: SphinxTestApp, status: StringIO, warning: StringIO, mo
914949
try:
915950
assert result.strip() == dedent(expected).strip()
916951
except Exception:
917-
print("Result was:\n", result, "\n\n")
952+
print(f"Result was:\n{result}\n\n")
918953
raise

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy