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

Option to remove unsupported annotations from numpy.ndarray and List in stubgen #12992

Open
birgerbr opened this issue Jun 17, 2022 · 0 comments

Comments

@birgerbr
Copy link

Feature

Command-line arguments for stubgen that when enabled will remove unsupported annotations from numpy.ndarray and List
like numpy.ndarray[numpy.float32[3,1]] and List[float[3]] which pybind11 outputs.

FYI: This feature has been implemented for numpy.ndarray in pybind11-stubgen.

Pitch

The stubs generated from extensions made with pybind11 using mypy.stubs are invalid when Eigen types or std::array are used in the interface.

As an example, this output from stubgen,

    def as_numpy(self) -> numpy.ndarray[numpy.float32[3,1]]: ...

will give the following errors when used together with Mypy:

error: Bad number of arguments for type alias, expected: 0, given: 2
error: "ndarray" expects 2 type arguments, but 1 given
error: Invalid type: try using Literal[2] instead?
error: Invalid type: try using Literal[1] instead?

And this

def split(axis_aligned_bounding_box: AxisAlignedBoundingBox, max_extents: List[float[3]]) -> List[AxisAlignedBoundingBox]: ...

will give these errors:

error: "float" expects no type arguments, but 1 given
error: Invalid type: try using Literal[3] instead?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants