MCPcopy Index your code
hub / github.com/RustPython/RustPython / repr_str

Method repr_str

crates/vm/src/builtins/staticmethod.rs:177–197  ·  view source on GitHub ↗
(zelf: &Py<Self>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

175
176impl Representable for PyStaticMethod {
177 fn repr_str(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
178 let callable = zelf.callable.lock().repr(vm).unwrap();
179 let class = Self::class(&vm.ctx);
180
181 match (
182 class
183 .__qualname__(vm)
184 .downcast_ref::<PyStr>()
185 .map(|n| n.as_wtf8()),
186 class
187 .__module__(vm)
188 .downcast_ref::<PyStr>()
189 .map(|m| m.as_wtf8()),
190 ) {
191 (None, _) => Err(vm.new_type_error("Unknown qualified name")),
192 (Some(qualname), Some(module)) if module != "builtins" => {
193 Ok(format!("<{module}.{qualname}({callable})>"))
194 }
195 _ => Ok(format!("<{}({})>", class.slot_name(), callable)),
196 }
197 }
198}
199
200pub fn init(context: &'static Context) {

Callers

nothing calls this directly

Calls 8

ErrClass · 0.50
unwrapMethod · 0.45
reprMethod · 0.45
lockMethod · 0.45
mapMethod · 0.45
__qualname__Method · 0.45
as_wtf8Method · 0.45
__module__Method · 0.45

Tested by

no test coverage detected