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

Some weird exceptions when building #5306

Closed
wqh17101 opened this issue Aug 16, 2018 · 5 comments
Closed

Some weird exceptions when building #5306

wqh17101 opened this issue Aug 16, 2018 · 5 comments

Comments

@wqh17101
Copy link

Subject:
Some weird exceptions happened when building
the rtd detailed issues
readthedocs/readthedocs.org#4528

Problem

When i use the RTD to build the doc,i meet an exception
then i build it locally ,but also get the same problem

Procedure to reproduce the problem

make html

Error logs / results

image
sphinx-err-nwwq7ojq.log

the failed build
https://readthedocs.org/projects/matchzoo/builds/7644468/

Expected results

generate normally

Reproducible project / your project

https://github.com/faneshion/MatchZoo/tree/hotfix/doc

Environment info

  • OS: Linux and Windows
  • Python version: python3.6
  • Sphinx version: 1.75
@tk0miya
Copy link
Member

tk0miya commented Aug 16, 2018

It seems hotfix/doc branch was removed. Please let me know how to reproduce the error.

@wqh17101
Copy link
Author

wqh17101 commented Aug 16, 2018

i found the reason and fixed it . Thank you for your help. There were something wrong for typehints.
NTMC-Community/MatchZoo#290
you can see this @tk0miya

@tk0miya
Copy link
Member

tk0miya commented Aug 17, 2018

Thank you for information. I found the error.

This is caused by a bug of utility function of Sphinx: sphinx.ext.autodoc.inspector:formatargspec(). But unfortunately, it is not used in sphinx-core because it is deprecated internally. In this case, it is called by sphinx_autodoc_typehints extension.

I'll fix the function later.

Note: typing.get_type_hints raises an exception if subject has broken type hints:

$ cat t.py
import typing

def func(arg: "unknown_type"):
    pass

typing.get_type_hints(func)
$ python -V
Python 3.6.5
$ python t.py
Traceback (most recent call last):
  File "t.py", line 6, in <module>
    typing.get_type_hints(func)
  File "/Users/tkomiya/.pyenv/versions/3.6.5/lib/python3.6/typing.py", line 1535, in get_type_hints
    value = _eval_type(value, globalns, localns)
  File "/Users/tkomiya/.pyenv/versions/3.6.5/lib/python3.6/typing.py", line 350, in _eval_type
    return t._eval_type(globalns, localns)
  File "/Users/tkomiya/.pyenv/versions/3.6.5/lib/python3.6/typing.py", line 245, in _eval_type
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
NameError: name 'unknown_type' is not defined

Since 1.7, autodoc module uses sphinx.util.inspect:Signature instead. In the class, any exceptions from get_type_hints() are handled.

@wqh17101
Copy link
Author

That is great. @tk0miya

tk0miya added a commit that referenced this issue Aug 17, 2018
…hints

Fix #5306: autodoc: ``getargspec()`` raises NameError for invalid typehints
@tk0miya
Copy link
Member

tk0miya commented Aug 17, 2018

Fixed by #5309.
Thank you for reporting.

@tk0miya tk0miya closed this as completed Aug 17, 2018
tk0miya added a commit that referenced this issue Aug 18, 2018
Fix #5306: autodoc: emit a warning for invalid typehints
@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

2 participants