Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 22, 2024
1 parent c0c174b commit 86259d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/sphinx_autodoc_typehints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
9 changes: 5 additions & 4 deletions tests/test_integration_issue_384.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -67,6 +67,7 @@ def function1(x: int, y: int, z: int) -> str: # noqa: ARG001
:rtype: bytes
"""


@expected(
"""\
mod.function(x=5)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 86259d6

Please sign in to comment.