-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
sphinx 3.2.0: trouble with typing.get_type_hints
#8099
Comments
…PE_CHECKING `typing.get_type_hints()` raises NameError when the target object contains unresolavable type annotation (ex. TYPE_CHECKING). This handles the exception and use unresolved annotations for type hints.
Sorry for the inconvenience. I posted #8108 to fix your error. Could you confirm it please? |
…PE_CHECKING `typing.get_type_hints()` raises NameError when the target object contains unresolavable type annotation (ex. TYPE_CHECKING). This handles the exception and use unresolved annotations for type hints.
…PE_CHECKING `typing.get_type_hints()` raises NameError when the target object contains unresolavable type annotation (ex. TYPE_CHECKING). This handles the exception and use unresolved annotations for type hints.
Thank you very much for your quick help. Due to commit 611fff9 sphinx generates the documentation of hydpy without any errors again. It is great that Sphinx now understands annotations including those written as forward references. However, due to commit 611fff9 just falling back to the standard Maybe it is more a question for enhancement than for a bugfix, but is there already a recommended way to give In hydpy, we generally import complete modules (and not only the required members) without changing their names. Hence, all we need is to pass all relevant modules and their names to To check that it principally works, I added the following simple
When I use
So, at least for us, accepting a callback function would be sufficient. |
Thank you for your confirmation! I'll merge and release it soon. About |
Fix #8099: autodoc: NameError is raised when script uses TYPE_CHECKING
Since 3.2.0, I cannot apply sphinx on my project (neither on Travis-CI nor locally):
typingtools
is module only required for typing purposes. Hence, I import it as follows:The problem starts in method
AttributeDocumenter.add_directive_header()
in lineannotations = get_type_hints(self.parent)
.If I apply the following manually, I get the same error:
When I add module
typingtools
to the local variables, everything seems to work:My project: https://github.com/hydpy-dev/hydpy/tree/develop.
The text was updated successfully, but these errors were encountered: