'How to add documentation to base class method without overriding it?

Is it possible to add documentation to a base class method without overriding it?

Arguments forwarding doesn't count as it is still overriding.

For example, we have the Base class:

class Base:

    def foo(self):
        print("Base.foo")

In the Derived class, I want to add documentation to foo, without overriding it.

class Derived:

    def foo(self):
        """Compute important stuff."""
        # this is already overriding though


# use
d = Derived()
d.foo() # print "Base.foo"

A little bit more context:

The Base class is implemented in a C extension. I have something like:

static PyMethodDef Base_methods[] = {
    {"foo", (PyCFunction)Base_foo, METH_NOARGS, "foo()\n--\n\nCompute important stuff."},
    {NULL},
};

But still, the IDE (vscode python) cannot even auto-complete the methods, let alone figure out the method docs.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source