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

Intersphinx typehints are not properly parsed #483

Open
wolearyc opened this issue Sep 24, 2024 · 0 comments
Open

Intersphinx typehints are not properly parsed #483

wolearyc opened this issue Sep 24, 2024 · 0 comments

Comments

@wolearyc
Copy link

wolearyc commented Sep 24, 2024

Hi,

First of all, thanks so much for your work on this package! I've been considering transitioning to autoapi from sphinx-apidoc, but autoapi seems to be having trouble translating my type hints into nice, fully-hyperlinked types. Things seem to fail especialy when using type aliases and/or bracket notation. I've reproduced the problem in this toy example:
https://github.com/wolearyc/autoapi-test.

Python file

"""Main file."""

import numpy as np
from numpy.typing import NDArray
from typing import Sequence, Any


def function_a(x: NDArray[np.float64]):
    """Do something.

    Parameters
    ----------
    x
        type hint doesn't link
    """
    pass


def function_b(x: NDArray):
    """Do something.

    Parameters
    ----------
    x
        type hint doesn't link
    """
    pass


def function_b(x: np.ndarray):
    """Do something.

    Parameters
    ----------
    x
        type hint works as expected
    """
    pass


def function_b(x: np.ndarray[Any, np.dtype[np.float64]]):
    """Do something.

    Parameters
    ----------
    x
        bits of pieces of the type are linked properly
    """
    pass

Sphinx generates the following documentation:

image

I think intersphinx is working properly, as in some cases the suitable links are generated. However, link generation fails in many of the cases. All of this works seamlessly with sphinx-apidoc (for example, see my current docs here https://ramannoodle.readthedocs.io/en/latest/generated/ramannoodle.dynamics.html), so I'm not sure what's going on.

Hopefully this is a simple fix and/or a silly goof on my part!

OS: MacOS 14.6
Python: 3.12.4
autoapi: 3.3.1
Sphinx: 8.0.2
sphinx-autodoc-typehints: 2.4.4

@wolearyc wolearyc changed the title Intersphinx typehints not documenting properly Intersphinx typehints are not properly parsed Sep 24, 2024
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