Closed mdorier closed 1 year ago
Hi! Thanks for the report.
I don't think that the solution you propose would work for everyone. And probably there would be none until python provides a counterpart to buffer protocol. The alternatives I'm thinking of are not great either, so I'm unsure how to proceed.
By the way, are there other similar protocols/structures not exposed to the python interpreter? There should be just a handful of them.
PEP 688 – Making the buffer protocol accessible in Python: https://peps.python.org/pep-0688/
In the meantime, PEP 688 was accepted. I've added the renaming buffer -> typing_extenensions.Buffer
Here are the relevant parts of tests and implementation.
Similar to issue https://github.com/sizmailov/pybind11-stubgen/issues/86 but when using
pybind11::buffer
. This time the solution is not as simple as adding aclass buffer
, because apybind11::buffer
represents any class that satisfies the buffer protocol, and there doesn't seem to be a generic class in typing for that (see https://github.com/python/typing/issues/593).Not sure what the solution should be. For now I have manually added
buffer = typing.Any
just to silence errors.