Skip to content

Commit 385fb03

Browse files
Merge pull request RustPython#327 from ZapAnton/float_doc
Float type: Added __doc__
2 parents 3d2d045 + 2d7164d commit 385fb03

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

vm/src/obj/objfloat.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ fn float_pow(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
268268

269269
pub fn init(context: &PyContext) {
270270
let float_type = &context.float_type;
271+
272+
let float_doc = "Convert a string or number to a floating point number, if possible.";
273+
271274
context.set_attr(&float_type, "__eq__", context.new_rustfunc(float_eq));
272275
context.set_attr(&float_type, "__lt__", context.new_rustfunc(float_lt));
273276
context.set_attr(&float_type, "__le__", context.new_rustfunc(float_le));
@@ -291,4 +294,9 @@ pub fn init(context: &PyContext) {
291294
context.set_attr(&float_type, "__pow__", context.new_rustfunc(float_pow));
292295
context.set_attr(&float_type, "__sub__", context.new_rustfunc(float_sub));
293296
context.set_attr(&float_type, "__repr__", context.new_rustfunc(float_repr));
297+
context.set_attr(
298+
&float_type,
299+
"__doc__",
300+
context.new_str(float_doc.to_string()),
301+
);
294302
}

0 commit comments

Comments
 (0)