Skip to content

Nitpick flags Literal annotation values as missing py:class (with type hints in description) #9775

@Spectre5

Description

@Spectre5

Describe the bug

This is basically the same issue as #9576, which was fixed in #9602. However, I still get this issue when using autodoc_typehints = 'description'.

How to Reproduce

$ unzip attachment.zip
$ python3.9 -m venv .venv
$ . .venv/bin/activate
$ pip install sphinx
$ sphinx-build -b html -n -W docs docs/_build
Running Sphinx v4.2.0
making output directory... done
[autosummary] generating autosummary for: index.rst, rst/api.rst
[autosummary] generating autosummary for: <snip>/docs/rst/generated/dummy.foo.bar.rst
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [100%] rst/generated/dummy.foo.bar                                                                                                                                                                                                     
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] rst/generated/dummy.foo.bar                                                                                                                                                                                                      

Warning, treated as error:
<snip>/src/dummy/foo.py:docstring of dummy.foo.bar::py:class reference target not found: ''

Comment out the line autodoc_typehints = 'description' in docs/conf.py and it is successful, as shown below (and removing the build artifacts to start fresh).

$ sphinx-build -b html -n -W docs docs/_build
Running Sphinx v4.2.0
making output directory... done
[autosummary] generating autosummary for: index.rst, rst/api.rst
[autosummary] generating autosummary for: <snip>/docs/rst/generated/dummy.foo.bar.rst
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: [new config] 3 added, 0 changed, 0 removed
reading sources... [100%] rst/generated/dummy.foo.bar                                                                                                                                                                                                     
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] rst/generated/dummy.foo.bar                                                                                                                                                                                                      
generating indices... genindex py-modindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.

The HTML pages are in docs/_build.

attachment.zip

Expected behavior

No error, the build should succeed.

Your project

See attachment in "How to Reproduce" section

Screenshots

N/A - output is shown in "How to Reproduce" section

OS

Linux and Windows

Python version

3.9

Sphinx version

4.2.0

Sphinx extensions

sphinx.ext.autodoc, sphinx.ext.autosummary

Extra tools

N/A

Additional context

This re-produces for me on both Linux and Windows. I think the source of it issue is probably from this line in merge_typehints since this function would otherwise be skipped if the type hints are left in the signature. But I haven't yet been able to track it all the way down to the error.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions