Issue description
Currently when declaring an operator method, the type signature in the docstring is not changed to include the additional type. In the example below we see the docstring:
__eq__(self: my_class.MyClass, arg0: my_class.MyClass) -> bool
however I would expect it to include the additional type signature that is more generic:
__eq__(*args, **kwargs)
Overloaded function.
1. __eq__(self: my_class.MyClass, arg0: my_class.MyClass) -> bool
2. __eq__(self: my_class.MyClass, arg0: object) -> NotImplemented
The use case where this is coming up:
I'm generating type stubs of a pybind module using stubgen. When running mypy with the generated stubs I see the following error:
Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
Reproducible example code
# include <pybind11/pybind11.h>
namespace py = pybind11;
class MyClass
{
MyClass(int id) : m_id(id);
int m_id;
};
PYBIND11_MODULE(my_class, m) {
py::class_<MyClass>(m, "MyClass")
.def("__eq__",
[](const MyClass& self, const MyClass& other) {
return self.m_id == other.m_id;
},
py::is_operator()
)
;
}
>>> import my_class
>>> my_class.MyClass.__eq__.__doc__
'__eq__(self: my_class.MyClass, arg0: my_class.MyClass) -> bool\n'
Issue description
Currently when declaring an operator method, the type signature in the docstring is not changed to include the additional type. In the example below we see the docstring:
however I would expect it to include the additional type signature that is more generic:
The use case where this is coming up:
I'm generating type stubs of a pybind module using stubgen. When running mypy with the generated stubs I see the following error:
Reproducible example code