Open
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
Problem description
When passing a C++ instance as a pointer, the default behaviour is to accept None
as described in the documentation. Consider the following example:
py::class_<Dog>(m, "Dog").def(py::init<>());
m.def("bark",
[](const Dog* dog) { return dog ? "woof!" : "(no dog)"; },
py::arg("dog")=py::none());
The function signature in help(module)
looks like this:
FUNCTIONS
bark(...) method of builtins.PyCapsule instance
bark(dog: module.Dog = None) -> str
but we would expect this signature instead:
FUNCTIONS
bark(...) method of builtins.PyCapsule instance
bark(dog: Optional[module.Dog] = None) -> str
I tested with pybind11 2.7.1.
Reproducible example code
No response