Skip to content

Commit ee34d41

Browse files
authored
Fix IndexError for line and keyword split (#261)
1 parent 73c6dfe commit ee34d41

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: trailing-whitespace
1414
- repo: https://github.com/asottile/pyupgrade
15-
rev: v2.37.3
15+
rev: v2.38.2
1616
hooks:
1717
- id: pyupgrade
1818
args: ["--py37-plus"]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ authors = [{ name = "Bernát Gábor", email = "[email protected]" }]
1717
maintainers = [{ name = "Bernát Gábor", email = "[email protected]" }]
1818
requires-python = ">=3.7"
1919
dependencies = ["Sphinx>=5.2.1"]
20-
optional-dependencies.docs = ["furo>=2022.9.15", "sphinx>=5.2.1", "sphinx-autodoc-typehints>=1.19.2"]
20+
optional-dependencies.docs = ["furo>=2022.9.15", "sphinx>=5.2.1", "sphinx-autodoc-typehints>=1.19.3"]
2121
optional-dependencies.testing = [
2222
"covdefaults>=2.2",
2323
"coverage>=6.4.4",

src/sphinx_autodoc_typehints/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ def _get_sphinx_line_keyword_and_argument(line: str) -> tuple[str, str | None] |
519519

520520
split_directive_and_name = param_line_without_description[1].split(maxsplit=1) # noqa: SC200
521521
if len(split_directive_and_name) != 2:
522+
if not len(split_directive_and_name):
523+
return None
522524
return (split_directive_and_name[0], None)
523525

524526
return tuple(split_directive_and_name) # type: ignore

tests/roots/test-dummy/dummy_module.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ def function_with_starred_documentation_param_names(*args: int, **kwargs: str):
130130
r"""
131131
Function docstring.
132132
133+
Usage::
134+
135+
print(1)
136+
133137
:param \*args: foo
134138
:param \**kwargs: bar
135139
"""

tests/test_sphinx_autodoc_typehints.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,10 @@ class InnerClass
623623
624624
Function docstring.
625625
626+
Usage:
627+
628+
print(1)
629+
626630
Parameters:
627631
* ***args** ("int") -- foo
628632

0 commit comments

Comments
 (0)