diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bda701c7..255a3876 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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"] diff --git a/pyproject.toml b/pyproject.toml index cdebbe87..70f6375d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/src/sphinx_autodoc_typehints/__init__.py b/src/sphinx_autodoc_typehints/__init__.py index cbfa5267..6c60ff56 100644 --- a/src/sphinx_autodoc_typehints/__init__.py +++ b/src/sphinx_autodoc_typehints/__init__.py @@ -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 diff --git a/tests/roots/test-dummy/dummy_module.py b/tests/roots/test-dummy/dummy_module.py index d94c7dda..a3c9fccd 100644 --- a/tests/roots/test-dummy/dummy_module.py +++ b/tests/roots/test-dummy/dummy_module.py @@ -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 """ diff --git a/tests/test_sphinx_autodoc_typehints.py b/tests/test_sphinx_autodoc_typehints.py index 2b6fde03..2e5fd8c0 100644 --- a/tests/test_sphinx_autodoc_typehints.py +++ b/tests/test_sphinx_autodoc_typehints.py @@ -623,6 +623,10 @@ class InnerClass Function docstring. + Usage: + + print(1) + Parameters: * ***args** ("int") -- foo