Subject: WARNING: error while formatting arguments for xxx.XXX: 'ForwardRef' object has no attribute '__origin__' on python 3.7
from typing import Optional
class Node(object):
"""Node class."""
def __init__(self, parent_node: Optional['Node']) -> None:
self._parent = parent_node
git clone https://github.com/miyakogi/sphinx_py37
cd sphinx_py37
(make new venv and install sphinx if needed)
cd docs
make html
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.
No warning and type hints in the result.
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.
Most helpful comment
OMG, #5300 breaks
Anyannotation... I'm very sorry. I'll fix it later.