Skip to content

NumPy NDArray typing conflict with numpydoc for np.integer. #633

Open
@mattgebert

Description

@mattgebert

Why:
Numpydoc ought to support annotations matching the typing functionality of numpy.typing and the built-in scalar types.

What:
I am using NumPy 2.3.0, and numpydoc 1.8.0.
I was writing some typed code using the NDArray dtype specifications, and found numpydoc would raise PR06 for the 'integer' keyword found in the scalar in-built numpy dtype integer.

import numpy as np, numpy.typing as npt
a : npt.NDArray[np.floating | np.integer]

When writing docstrings for such typing, numpydoc throws a PR06 error, due to the inclusion of the integer string.

Parameter "a" type should use "int" instead of "integer"

What I expected:
In the context of using numpy.typing and np.integer, I didn't expect to see numpydoc raise an error for a valid numpy in-build scalar datatype.

How we might solve this:
Either numpy / numpy.typing ought to be using the same rules (i.e. int instead of integer, float instead of floating etc) to represent the in-built dtypes, or (more likely) numpydoc should accommodate this labeling?

I also noticed we added an exclusion case for PR06 via skipping over the "{" character, for option sets defined by braces/curly-brackets in this issue / PR.

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