sizmailov / pybind11-stubgen

Generate stubs for python modules
Other
232 stars 47 forks source link

error: Name "capsule" is not defined #86

Closed mdorier closed 1 year ago

mdorier commented 1 year ago

I have a pybind11-based library that uses capsules (pybind11::capsule). When I try to use the stubs generated by pybind11-stubgen with mypy, I'm getting a lot of errors like the following:

stubs/_pymargo-stubs/__init__.pyi:318: error: Name "capsule" is not defined

This can be fixed by manually adding the "capsule" class to init.pyi, but it would be better if pybind11-stubgen could do it by itself.

sizmailov commented 1 year ago

Hi, thanks for the report.

PyCapsule does not provide any python interface to interact with, therefore it would be perfectly fine to annotate it as Any

_my_capsule: typing.Any  # PyCapsule()

... or even remove it from the stubs altogether (since you can't do much with it from python).

I'm inclined to implement the first option.

sizmailov commented 1 year ago

Closed by 106712441fd5ce4d6a6130d7c52d5b9160ac0738