Skip to content

Commit 869b91a

Browse files
Merge pull request RustPython#399 from ZapAnton/super_doc
super type: Added __doc__
2 parents 32bfcf3 + 2b0f87b commit 869b91a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

vm/src/obj/objsuper.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,27 @@ use super::objtype;
1212

1313
pub fn init(context: &PyContext) {
1414
let super_type = &context.super_type;
15+
16+
let super_doc = "super() -> same as super(__class__, <first argument>)\n\
17+
super(type) -> unbound super object\n\
18+
super(type, obj) -> bound super object; requires isinstance(obj, type)\n\
19+
super(type, type2) -> bound super object; requires issubclass(type2, type)\n\
20+
Typical use to call a cooperative superclass method:\n\
21+
class C(B):\n \
22+
def meth(self, arg):\n \
23+
super().meth(arg)\n\
24+
This works for class methods too:\n\
25+
class C(B):\n \
26+
@classmethod\n \
27+
def cmeth(cls, arg):\n \
28+
super().cmeth(arg)\n";
29+
1530
context.set_attr(&super_type, "__init__", context.new_rustfunc(super_init));
31+
context.set_attr(
32+
&super_type,
33+
"__doc__",
34+
context.new_str(super_doc.to_string()),
35+
);
1636
}
1737

1838
fn super_init(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {

0 commit comments

Comments
 (0)