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

Created on 13 Aug 2018  路  9Comments  路  Source: sphinx-doc/sphinx

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
autodoc bug

Most helpful comment

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

All 9 comments

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

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

oh, sorry. I just reopened.

Fixed by #5303.
Thank you for reporting!

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

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

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

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

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

Was this page helpful?
0 / 5 - 0 ratings