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
Warnings raised on variable and attribute type annotations #7808
Comments
We have a similar problem in the Trio project where we use annotations like "str or list", ThisType or None" or even "bytes-like" in a number of place. Here's an example: https://github.com/python-trio/trio/blob/dependabot/pip/sphinx-3.1.0/trio/_subprocess.py#L75-L96 |
To clarify a bit on the Trio issue: we don't expect sphinx to magically do anything with
And with previous versions of Sphinx, it renders like this: https://trio.readthedocs.io/en/v0.15.1/reference-io.html#trio.Process.args Notice that So Sphinx used to be able to cope with this kind of "or" syntax, and if it can't anymore it's a regression. |
This also occurs with built-in container classes and 'or'-types (in nitpick mode):
Unfortunately this breaks my CI pipeline at the moment. Does anyone know a work-around other than disabling nitpick mode? |
…te type annotations
Unfortunately even with #7814 I still see the same warning: If you want to try it out, we run Is there anything we can do to help here? |
Hmm... the trio's case came from #7583. |
Fix #7808: autodoc: Warnings raised on variable and attribute type annotations
Instead of reverting it, can we just silence the warning, and revert to the old behavior if parsing fails? |
It can suppress a part of nitpicky warnings. But numpydoc allows some kinds of python-valid type descriptions: |
Perhaps then |
I don't have idea to realize it now. I'll try it tomorrow. Please let me know if you have idea. |
Finally, I can't find the way to skip conversion for non-pep484 descriptions. So I'll revert it from 3.1.x. Let's reconsider it again for 3.2.0. |
Thanks! 3.1.1 fixed the issue. |
Thank you for the quick resolution! 🙂 |
This issue happens again on 3.2.0. It works on 3.1.2. |
Describe the bug
autodoc signature for non-builtin types raises warning and thus fails nitpicking:
To Reproduce
Steps to reproduce the behavior:
Create a file
foo.py
with the following content:Use sphinx-apidoc to generate an rst file, while enabling autodoc and intersphinx:
sphinx-apidoc --ext-autodoc --ext-intersphinx
Make sure the
intersphinx_mapping
in the Sphinxconf.py
contains"python": ("https://docs.python.org/3.8/", None),
Run
make html
with loud warnings and nitpicking:SPHINXOPTS="-n -v -W --keep-going" make html
.You will get an error message
Expected behavior
I'd expect Sphinx to resolve the type annotation
Optional[str]
and possibly link both classes.Environment info
Additional context
I think the issue stems from the change in 88e8ebb which appears to try to lookup the entire type annotation as a single class.
Using
_parse_annotation()
instead oftype_to_xref()
solves this particular issue:However, it doesn't seem to work with custom classes. Take this snippet for example:
This causes the following warning:
The text was updated successfully, but these errors were encountered: