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

[BUG]: array_t stub is incorrect. #5352

Open
3 tasks done
gentlegiantJGC opened this issue Sep 3, 2024 · 1 comment
Open
3 tasks done

[BUG]: array_t stub is incorrect. #5352

gentlegiantJGC opened this issue Sep 3, 2024 · 1 comment
Labels
triage New bug, unverified

Comments

@gentlegiantJGC
Copy link
Contributor

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.13.5

Problem description

The stub files generated by handle_type_name are incorrect for array_t.

The correct type hint for py::array_t<std::uint32_t> should be one of:

  1. numpy.ndarray[typing.Any, numpy.uint32] First argument is shape, second argument is type.
  2. numpy.typing.NDArray[numpy.uint32] Only argument is type.

but pybind creates numpy.ndarray[numpy.uint32] which raises the following mypy error.

error: "ndarray" expects 2 type arguments, but 1 given

Doc: https://numpy.org/doc/1.21/reference/typing.html#numpy.typing.NDArray

Is there some reason why this is wrong?
I can submit a pull request if you tell me which form you prefer.

Reproducible example code

No response

Is this a regression? Put the last known working version here if it is.

Not a regression

@gentlegiantJGC gentlegiantJGC added the triage New bug, unverified label Sep 3, 2024
@gentlegiantJGC
Copy link
Contributor Author

#5212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage New bug, unverified
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant