Skip to content

Arguments and return type hints are fully qualified although they should not be #389

@peske

Description

@peske

First, thanks for the great work!

Let me describe the problem on the real-world example. My function is defined in the following way:

from collections.abc import Sequence

from nptyping import Float64, NDArray, Shape


def create_operator_matrices(  # noqa: C901
    relative_radii: Sequence[float],
    r_min: float | None = None,
) -> tuple[NDArray[Shape["N, N"], Float64], NDArray[Shape["N, N"], Float64]]:
    pass

The extension configuration:

# typehints_fully_qualified = False
# always_document_param_types = False
# typehints_document_rtype = True
# typehints_use_rtype = True
typehints_defaults = "braces"
# simplify_optional_unions = True
# typehints_formatter = None
typehints_use_signature = True
typehints_use_signature_return = True

The resulting function signature in the generated docs:

grc.create_operator_matrices(relative_radii: collections.abc.Sequence[float], r_min: float | None = None) → tuple[nptyping.ndarray.NDArray[nptyping.base_meta_classes.Shape[N, N], numpy.float64], nptyping.ndarray.NDArray[nptyping.base_meta_classes.Shape[N, N], numpy.float64]]

Parameters in the resulting docs are as follows:

relative_radii: collections.abc.Sequence[float]

The problem is obvious: instead of having things like nptyping.ndarray.NDArray and nptyping.base_meta_classes.Shape[N, N], I expect simply NDArray and Shape[N, N].

Strangely enough, the "Return type" section of the generated documentation looks more or less ok:

tuple[NDArray[Shape[N, N], float64], NDArray[Shape[N, N], float64]]

The only problem with the "Return type" is that it uses float64 instead of Float64 (see the actual function signature).

Any help will be appreciated!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions