sphinx-doc / sphinx-doc/sphinx

Typhint optional parameters with google style and pep484 typhints does not work.

Open
#10,141 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

The autodoc_typehints = 'both' option does not work with optional parameters in Google Python
Style docs with pep484_type_annotations typed functions.

Just as a side note but not part of this issue:
The docs are completly missing in the signature for non pep484 style.

How to Reproduce
$ #  Unzip.
$ pip install -r sphinx
$ cd unziped folder
$ make html
$ # open _build/html/index and see param2 in module_level_function vs module_level_function_pep484
Expected behavior

I would expect that param2 in docstring is documented the same and the type is added. so in module_level_function_pep484() is also param2 (str, optional) - The .....

Your project

docs.zip

Screenshots

grafik

OS

Debian GNU/Linux 11 (bullseye)

Python version

Python 3.8.12

Sphinx version

4.4.0

Sphinx extensions

'sphinx.ext.autodoc', 'sphinx.ext.napoleon'

Extra tools

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by unpacking docs.zip, installing the requirements, and running make html with sphinx.ext.autodoc and sphinx.ext.napoleon enabled. Compare the generated documentation for module_level_function and module_level_function_pep484; done means the optional parameter is documented consistently with its type and description.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.