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

Method set___annotations__

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

Source from the content-addressed store, hash-verified

394
395 #[pygetset(setter)]
396 fn set___annotations__(
397 zelf: &Py<Self>,
398 value: PySetterValue,
399 vm: &VirtualMachine,
400 ) -> PyResult<()> {
401 let dict = zelf.dict();
402 match value {
403 PySetterValue::Assign(value) => {
404 dict.set_item(identifier!(vm, __annotations__), value, vm)?;
405 // Clear __annotate__ from dict
406 dict.del_item(identifier!(vm, __annotate__), vm).ok();
407 Ok(())
408 }
409 PySetterValue::Delete => {
410 if dict.del_item(identifier!(vm, __annotations__), vm).is_err() {
411 return Err(vm.new_attribute_error("__annotations__"));
412 }
413 // Also clear __annotate__
414 dict.del_item(identifier!(vm, __annotate__), vm).ok();
415 Ok(())
416 }
417 }
418 }
419}
420
421impl Initializer for PyModule {

Callers

nothing calls this directly

Calls 6

okMethod · 0.80
is_errMethod · 0.80
ErrClass · 0.50
dictMethod · 0.45
set_itemMethod · 0.45
del_itemMethod · 0.45

Tested by

no test coverage detected