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

doc generation failing due to typing imports #7

Open
fmigneault opened this issue Dec 4, 2021 · 0 comments
Open

doc generation failing due to typing imports #7

fmigneault opened this issue Dec 4, 2021 · 0 comments

Comments

@fmigneault
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant