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

Method __dir__

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

Source from the content-addressed store, hash-verified

298
299 #[pymethod]
300 fn __dir__(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> {
301 // First check if __dict__ attribute exists and is actually a dictionary
302 let dict_attr = zelf.as_object().get_attr(identifier!(vm, __dict__), vm)?;
303 let dict = dict_attr
304 .downcast::<PyDict>()
305 .map_err(|_| vm.new_type_error("<module>.__dict__ is not a dictionary"))?;
306 let attrs = dict.into_iter().map(|(k, _v)| k).collect();
307 Ok(attrs)
308 }
309
310 #[pygetset]
311 fn __annotate__(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyObjectRef> {

Callers

nothing calls this directly

Calls 5

collectMethod · 0.80
get_attrMethod · 0.45
as_objectMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected