sphinx-argparse
sphinx-argparse copied to clipboard
doc generation failing due to typing imports
When building docs with an sphinx-argparse
directive, the following error occurs.
[...]
File "/home/francis/dev/miniconda/envs/weaver-py3/lib/python3.7/site-packages/sphinxarg/ext.py", line 474, in run
exec(code, mod)
File "../weaver/cli.py", line 28, in <module>
from weaver.typedefs import CWL, HeadersType, JSON
File "/home/francis/dev/weaver/weaver/typedefs.py", line 34, in <module>
from weaver.processes.wps_process_base import WpsProcessInterface
File "/home/francis/dev/weaver/weaver/processes/wps_process_base.py", line 17, in <module>
from weaver.typedefs import CWL_RuntimeInputsMap
ImportError: cannot import name 'CWL_RuntimeInputsMap' from 'weaver.typedefs' (/home/francis/dev/weaver/weaver/typedefs.py)
where my directive is as follows:
.. argparse::
:module: weaver.cli
:func: make_parser
:prog: weaver
The encountered error happens due to a typing
import.
In the weaver.cli
module, there is this in the imports:
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from weaver.typedefs import CWL, HeadersType, JSON
Because this is within a typing-enabled block, it should be ignored for "normal" execution. Only typing parsers/linters must consider those imports, which I believe arparse shouldn't consider.
Note, this might be caused by interactions with package sphinx_autodoc_typehints
which uses those typings during documentation generation. I'm not familiar enough with the internals of sphinx building to know if sphinx-argparse
could disable typings only for its own context build.