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

WARNING: error while formatting arguments for xxx.XXX: 'ForwardRef' object has no attribute '__origin__' on python 3.7 #5291

Closed
miyakogi opened this issue Aug 13, 2018 · 9 comments

Comments

@miyakogi
Copy link
Contributor

Subject: WARNING: error while formatting arguments for xxx.XXX: 'ForwardRef' object has no attribute '__origin__' on python 3.7

Problem

  • This warning is raised on python3.7 with autodoc of the below code and type hints does not made in output.
from typing import Optional

class Node(object):
    """Node class."""

    def __init__(self, parent_node: Optional['Node']) -> None:
        self._parent = parent_node

Procedure to reproduce the problem

git clone https://github.com/miyakogi/sphinx_py37
cd sphinx_py37
(make new venv and install sphinx if needed)
cd docs
make html

Error logs / results

Output:

WARNING: error while formatting arguments for sphinx_py37.Node: 'ForwardRef' object has no attribute '__origin__'

And type hints are not exist in the output HTML.

Expected results

No warning and type hints in the result.

Reproducible project / your project

Environment info

  • OS: Linux (Arch Linux) and Windows 10 home
  • Python version: 3.7.0
  • Sphinx version: 1.7.6 and 1.8.0.dev20180813
@tk0miya
Copy link
Member

tk0miya commented Aug 13, 2018

Fortunately, we just fixed it by #5280. It will be released as 1.7.7 soon.
Thanks,

@miyakogi
Copy link
Contributor Author

Thank you for quick response.
But this error still exists on both sphinx 1.7.7.dev20180814 and 1.8.0.dev20180814.

@tk0miya
Copy link
Member

tk0miya commented Aug 14, 2018

oh, sorry. I just reopened.

@tk0miya tk0miya reopened this Aug 14, 2018
@tk0miya tk0miya self-assigned this Aug 14, 2018
tk0miya added a commit to tk0miya/sphinx that referenced this issue Aug 15, 2018
tk0miya added a commit that referenced this issue Aug 16, 2018
@tk0miya
Copy link
Member

tk0miya commented Aug 16, 2018

Fixed by #5303.
Thank you for reporting!

@tk0miya tk0miya closed this as completed Aug 16, 2018
@terrisgit
Copy link

Is this fix in 1.8.0b1 ? I am seeing a similar problem.

@astafan8
Copy link

astafan8 commented Aug 21, 2018

I am also getting a similar warning:
WARNING: error while formatting arguments for xxx.xxx.xxx: '_Any' object has no attribute '__origin__'

Where does it come from? What is the problem about? When and where is it fixed?

I don't know for sure but it seems that signatures with Any cause this warning for me, like:
def call(self, func_name: str, *args) -> Any:

@tk0miya

astafan8 added a commit to astafan8/Qcodes that referenced this issue Aug 21, 2018
Most probably the reason is in this sphinx issue:
sphinx-doc/sphinx#5291

Warnings that sphinx 1.7.7 gives look like this:
WARNING: error while formatting arguments for xxx.xxx.xxx:
'_Any' object has no attribute '__origin__'
garenchan added a commit to garenchan/tornado that referenced this issue Aug 21, 2018
See sphinx-doc/sphinx#5291
Always use 1.7.6 until `Sphinx` solves the bugs
@tk0miya
Copy link
Member

tk0miya commented Aug 21, 2018

OMG, #5300 breaks Any annotation... I'm very sorry. I'll fix it later.

@tk0miya
Copy link
Member

tk0miya commented Aug 21, 2018

Note: I made a issue #5322 for the problem on 1.7.7.

@tk0miya
Copy link
Member

tk0miya commented Aug 22, 2018

I fixed this again by #5333.
Could you check this please? You can test it with HEAD of 1.7 branch.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 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

4 participants