From 86259d666ad88ff850a10593accfe52037c576af Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 22 Jun 2024 01:46:32 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/sphinx_autodoc_typehints/__init__.py | 4 +--- tests/test_integration_issue_384.py | 9 +++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/sphinx_autodoc_typehints/__init__.py b/src/sphinx_autodoc_typehints/__init__.py index 6e68ee0..ae202d8 100644 --- a/src/sphinx_autodoc_typehints/__init__.py +++ b/src/sphinx_autodoc_typehints/__init__.py @@ -740,7 +740,6 @@ def _inject_signature( # noqa: C901 insert_index = len(lines) if insert_index is not None: - if annotation is None: type_annotation = f":type {arg_name}: " else: @@ -751,12 +750,11 @@ def _inject_signature( # noqa: C901 formatted_default = format_default(app, default, annotation is not None) if formatted_default: if app.config.typehints_defaults.endswith("after"): - # advance index to the end of the :param: paragraph nlines = len(lines) i = insert_index while i < nlines and (lines[i + 1] == "" or lines[i + 1].startswith(" ")): - i = i + 1 + i += 1 lines[i] += formatted_default diff --git a/tests/test_integration_issue_384.py b/tests/test_integration_issue_384.py index 83acef9..2e9f09c 100644 --- a/tests/test_integration_issue_384.py +++ b/tests/test_integration_issue_384.py @@ -4,7 +4,7 @@ import sys from pathlib import Path from textwrap import dedent, indent -from typing import TYPE_CHECKING, Any, Callable, Literal, NewType, TypeVar # no type comments +from typing import TYPE_CHECKING, Any, Callable, NewType, TypeVar # no type comments import pytest @@ -44,7 +44,7 @@ def dec(val: T) -> T: **x** ("int") -- optional specifier for how to handle complex data types. See "ivy.func_wrapper.handle_complex_input" for more detail. - + Returns: something @@ -67,6 +67,7 @@ def function1(x: int, y: int, z: int) -> str: # noqa: ARG001 :rtype: bytes """ + @expected( """\ mod.function(x=5) @@ -77,7 +78,7 @@ def function1(x: int, y: int, z: int) -> str: # noqa: ARG001 **x** ("int") -- optional specifier for how to handle complex data types. See "ivy.func_wrapper.handle_complex_input" for more detail. - + Returns: something @@ -89,7 +90,7 @@ def function(x: int = 5, y: int = 10, z: int = 5) -> str: # noqa: ARG001 """ Function docstring. - :param x: optional specifier + :param x: optional specifier line 2 :return: something