Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Spectre5 opened this issue Oct 26, 2021 · 2 comments

Comments

@Spectre5
Copy link

Spectre5 commented Oct 26, 2021

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.

@Spectre5
Copy link
Author

@tk0miya is there any additional info I can provide? Or any suggestions you can make to help me narrow down the source of this issue within the code base. I ran it also with -vvv and it provide the traceback, but it doesn't really provide any additional insight to me.

@tk0miya tk0miya added this to the 4.3.0 milestone Oct 30, 2021
@tk0miya
Copy link
Member

tk0miya commented Oct 30, 2021

Thank you for reporting. I reproduce the same error on my local. The example is expanded to the following mark-up on memory:

.. function:: bar(bar='')

   :param bar:
   :type bar: Literal['', 'f', 'd']

And the function directive failed to handle the Literal type.

tk0miya added a commit to tk0miya/sphinx that referenced this issue Oct 30, 2021
tk0miya added a commit that referenced this issue Oct 31, 2021
Fix #9775: py domain: Literal typehint was converted to a cross reference
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants