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

Method dir

crates/vm/src/vm/vm_object.rs:148–164  ·  view source on GitHub ↗
(&self, obj: Option<PyObjectRef>)

Source from the content-addressed store, hash-verified

146 }
147
148 pub fn dir(&self, obj: Option<PyObjectRef>) -> PyResult<PyList> {
149 let seq = match obj {
150 Some(obj) => self
151 .get_special_method(&obj, identifier!(self, __dir__))?
152 .ok_or_else(|| self.new_type_error("object does not provide __dir__"))?
153 .invoke((), self)?,
154 None => self.call_method(
155 self.current_locals()?.as_object(),
156 identifier!(self, keys).as_str(),
157 (),
158 )?,
159 };
160 let items: Vec<_> = seq.try_to_value(self)?;
161 let lst = PyList::from(items);
162 lst.sort(Default::default(), self)?;
163 Ok(lst)
164 }
165
166 #[inline]
167 pub(crate) fn get_special_method(

Callers 4

offer_suggestionsFunction · 0.45
dirFunction · 0.45
__dir__Method · 0.45
__dir__Method · 0.45

Calls 9

ok_or_elseMethod · 0.80
get_special_methodMethod · 0.80
current_localsMethod · 0.80
try_to_valueMethod · 0.80
invokeMethod · 0.45
call_methodMethod · 0.45
as_objectMethod · 0.45
as_strMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected