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

Regression: autodoc Dataclass variables reference target not found #7928

Closed
adamtheturtle opened this issue Jul 8, 2020 · 3 comments
Closed

Comments

@adamtheturtle
Copy link
Contributor

Describe the bug

When I use sphinx.ext.autodoc and nitpicky = True with my code which includes a dataclass with a variable of a custom type, I get a warning.

To Reproduce

Open the attached project sphinx-example.zip.
Install Sphinx.
Run sphinx-build -M html source/ build/.

Expected behavior

I expect there to be no warning, or a clear message saying how I can avoid this warning.

Your project

sphinx-example.zip

Environment info

macOS latest
Python 3.7.7
Sphinx 3.1.2 (reproducible also with 3.1.0 but not 3.0.4)

@tk0miya tk0miya added this to the 3.2.0 milestone Jul 8, 2020
@tk0miya
Copy link
Member

tk0miya commented Jul 8, 2020

Thank you for reporting.

Note: Internally, the autodoc generates the following code:

.. py:module:: example


.. py:class:: Report(status: example.Statuses)
   :module: example


   .. py:attribute:: Report.status
      :module: example
      :type: Statuses


.. py:class:: Statuses()
   :module: example

It seems the intermediate code is good. But py:attribute class does not process :type: Statuses option well.

@tk0miya
Copy link
Member

tk0miya commented Jul 8, 2020

A Dockerfile to reproduce the error:

FROM python:3.7-slim

RUN apt update; apt install -y build-essential curl git make unzip vim
RUN curl -LO https://github.com/sphinx-doc/sphinx/files/4890646/sphinx-example.zip
RUN unzip sphinx-example.zip
WORKDIR /sphinx-example
RUN pip install -U sphinx
RUN sphinx-build -NTvv source/ build/html/

@adamtheturtle
Copy link
Contributor Author

@tk0miya - It is great to see such open and quick progress. Thank you for your hard work on this.

tk0miya added a commit that referenced this issue Jul 11, 2020
Fix #7928: py domain: failed to resolve a type annotation for the attribute
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 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