NumPy NDArray typing conflict with numpydoc for `np.integer`.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 355
- Forks
- 181
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 3
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in numpydoc/validate.py around the PR06 handling at line 744, then review the linked issue 341 and pull request 347 for the existing curly-bracket exception. Confirm how np.integer appears in the annotation example and define completion as valid NumPy typing using integer no longer triggering PR06.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- documentation, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100