Skip to content

[BUG]: Invalid typing for std::array? #3912

Closed
@Holt59

Description

@Holt59

Required prerequisites

Problem description

When returning a std::array, the typing information is invalid, e.g. List[str[2]] for the code below. This causes tool such as mypy's stubgen or pybind11-stubgen to produce invalid stubs.

I guess it would be valid to generate List[str] in this case since Python does not have information about the size anyway?

Reproducible example code

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

namespace py = pybind11;

PYBIND11_MODULE(cpp_module, m)
{
    m.def("arr", []() -> std::array<const char*, 2> {
        return {"foo", "bar"};
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsignaturesIssue about static signatures

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions