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

Method set___annotate__

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

Source from the content-addressed store, hash-verified

323
324 #[pygetset(setter)]
325 fn set___annotate__(
326 zelf: &Py<Self>,
327 value: PySetterValue,
328 vm: &VirtualMachine,
329 ) -> PyResult<()> {
330 match value {
331 PySetterValue::Assign(value) => {
332 if !vm.is_none(&value) && !value.is_callable() {
333 return Err(vm.new_type_error("__annotate__ must be callable or None"));
334 }
335 let dict = zelf.dict();
336 dict.set_item(identifier!(vm, __annotate__), value.clone(), vm)?;
337 // Clear __annotations__ if value is not None
338 if !vm.is_none(&value) {
339 dict.del_item(identifier!(vm, __annotations__), vm).ok();
340 }
341 Ok(())
342 }
343 PySetterValue::Delete => Err(vm.new_type_error("cannot delete __annotate__ attribute")),
344 }
345 }
346
347 #[pygetset]
348 fn __annotations__(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyObjectRef> {

Callers

nothing calls this directly

Calls 8

is_callableMethod · 0.80
okMethod · 0.80
ErrClass · 0.50
is_noneMethod · 0.45
dictMethod · 0.45
set_itemMethod · 0.45
cloneMethod · 0.45
del_itemMethod · 0.45

Tested by

no test coverage detected