Skip to content

Intersphinx typehints are not properly parsed #483

Open
@wolearyc

Description

@wolearyc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions