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

autoclass digests types from typehint but numpy types are not linked via intersphinx #10746

Closed
1kastner opened this issue Aug 2, 2022 · 4 comments
Labels

Comments

@1kastner
Copy link

1kastner commented Aug 2, 2022

Describe the bug

I use numpy types in my function and method typehints. Unlike #10151, I do not want to repeat the types in the docstring. I prefer the types to show up in the signature and only there. Usually, Sphinx does a very decent job injecting the types into the signature. Here, also intersphinx comes into play and adds links to Python types such as integers, datetime objects, etc.

Recently, I added numpy to the stack. Somehow, intersphinx does not create links for these types even though its inventory is added to intersphinx_mapping.

How to Reproduce

$ git clone https://github.com/1kastner/conflowgen.git
$ cd conflowgen
$ pip install -e .[dev]
$ cd docs
$ make html
$ # open _build/html/api.html#using-distributions and see that intersphinx did not turn numpy.typing.ArrayLike into a link

Expected behavior

numpy.typing.ArrayLike should be detected by intersphinx and converted into a link

Your project

https://github.com/1kastner/conflowgen

Screenshots

Here, I played around and also included the typehints into the description of the class. Still no clickable links.

grafik

OS

Windows

Python version

3.9

Sphinx version

4.5

Sphinx extensions

['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.napoleon', 'sphinx.ext.mathjax', 'sphinx.ext.intersphinx', 'sphinx.ext.autosectionlabel', 'sphinx.ext.viewcode', 'sphinxcontrib.bibtex', 'myst_parser', 'sphinx_math_dollar', 'enum_tools.autoenum', 'sphinx_toolbox.more_autodoc.autonamedtuple', 'nbsphinx']

Extra tools

No response

Additional context

No response

@1kastner 1kastner changed the title Napoleon reads type from typehint but the numpy type is not linked via intersphinx Napoleon reads type from typehint but numpy types is not linked via intersphinx Aug 2, 2022
@1kastner 1kastner changed the title Napoleon reads type from typehint but numpy types is not linked via intersphinx Napoleon reads types from typehint but numpy types are not linked via intersphinx Aug 2, 2022
@1kastner 1kastner changed the title Napoleon reads types from typehint but numpy types are not linked via intersphinx autoclass reads types from typehint but numpy types are not linked via intersphinx Aug 2, 2022
@1kastner 1kastner changed the title autoclass reads types from typehint but numpy types are not linked via intersphinx autoclass digests types from typehint but numpy types are not linked via intersphinx Aug 3, 2022
@1kastner
Copy link
Author

1kastner commented Aug 3, 2022

@1kastner
Copy link
Author

1kastner commented Aug 3, 2022

Completely my bad. I did not import numpy.typing which I should have. No linter or heuristic in the IDE warned me and I was too overwhelmed with issues from the past (like I cited) to see that it was a simple user error...

@1kastner 1kastner closed this as completed Aug 3, 2022
@ryancoe
Copy link

ryancoe commented Aug 22, 2022

@1kastner - I'm having a similar issue. Where (in what file) were you missing the import numpy.typing call?

@1kastner
Copy link
Author

In the file that contained the auto-documented class.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants