Skip to content

Commit

Permalink
Fix IndexError for line and keyword split (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborbernat authored Sep 27, 2022
1 parent 73c6dfe commit ee34d41
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
rev: v2.38.2
hooks:
- id: pyupgrade
args: ["--py37-plus"]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ authors = [{ name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }]
maintainers = [{ name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }]
requires-python = ">=3.7"
dependencies = ["Sphinx>=5.2.1"]
optional-dependencies.docs = ["furo>=2022.9.15", "sphinx>=5.2.1", "sphinx-autodoc-typehints>=1.19.2"]
optional-dependencies.docs = ["furo>=2022.9.15", "sphinx>=5.2.1", "sphinx-autodoc-typehints>=1.19.3"]
optional-dependencies.testing = [
"covdefaults>=2.2",
"coverage>=6.4.4",
Expand Down
2 changes: 2 additions & 0 deletions src/sphinx_autodoc_typehints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ def _get_sphinx_line_keyword_and_argument(line: str) -> tuple[str, str | None] |

split_directive_and_name = param_line_without_description[1].split(maxsplit=1) # noqa: SC200
if len(split_directive_and_name) != 2:
if not len(split_directive_and_name):
return None
return (split_directive_and_name[0], None)

return tuple(split_directive_and_name) # type: ignore
Expand Down
4 changes: 4 additions & 0 deletions tests/roots/test-dummy/dummy_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def function_with_starred_documentation_param_names(*args: int, **kwargs: str):
r"""
Function docstring.
Usage::
print(1)
:param \*args: foo
:param \**kwargs: bar
"""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_sphinx_autodoc_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@ class InnerClass
Function docstring.
Usage:
print(1)
Parameters:
* ***args** ("int") -- foo
Expand Down

0 comments on commit ee34d41

Please sign in to comment.