Skip to content

Commit 4e584ef

Browse files
Merge pull request RustPython#374 from ZapAnton/set_doc
(frozen)set type: Added __doc__
2 parents c24a88c + 694cbda commit 4e584ef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

vm/src/obj/objset.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ fn frozenset_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
151151

152152
pub fn init(context: &PyContext) {
153153
let set_type = &context.set_type;
154+
155+
let set_doc = "set() -> new empty set object\n\
156+
set(iterable) -> new set object\n\n\
157+
Build an unordered collection of unique elements.";
158+
154159
context.set_attr(
155160
&set_type,
156161
"__contains__",
@@ -159,15 +164,26 @@ pub fn init(context: &PyContext) {
159164
context.set_attr(&set_type, "__len__", context.new_rustfunc(set_len));
160165
context.set_attr(&set_type, "__new__", context.new_rustfunc(set_new));
161166
context.set_attr(&set_type, "__repr__", context.new_rustfunc(set_repr));
167+
context.set_attr(&set_type, "__doc__", context.new_str(set_doc.to_string()));
162168
context.set_attr(&set_type, "add", context.new_rustfunc(set_add));
163169

164170
let frozenset_type = &context.frozenset_type;
171+
172+
let frozenset_doc = "frozenset() -> empty frozenset object\n\
173+
frozenset(iterable) -> frozenset object\n\n\
174+
Build an immutable unordered collection of unique elements.";
175+
165176
context.set_attr(
166177
&frozenset_type,
167178
"__contains__",
168179
context.new_rustfunc(set_contains),
169180
);
170181
context.set_attr(&frozenset_type, "__len__", context.new_rustfunc(set_len));
182+
context.set_attr(
183+
&frozenset_type,
184+
"__doc__",
185+
context.new_str(frozenset_doc.to_string()),
186+
);
171187
context.set_attr(
172188
&frozenset_type,
173189
"__repr__",

0 commit comments

Comments
 (0)