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

+4
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

+3
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

+36-1
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)