MCPcopy Create free account
hub / github.com/Houseofmvps/codesight / annotation_type

Function annotation_type

plugins/ast/python/src/lib.rs:666–685  ·  view source on GitHub ↗

Render an annotation to (type, nullable). `Optional[T]` / `Mapped[T]` unwrap.

(expression: &Expression)

Source from the content-addressed store, hash-verified

664
665/// Render an annotation to (type, nullable). `Optional[T]` / `Mapped[T]` unwrap.
666fn annotation_type(expression: &Expression) -> (String, bool) {
667 match expression {
668 Expression::Name(NameExpression { id, .. }) => (id.to_string(), false),
669 Expression::Subscript(value) => {
670 let Expression::Name(NameExpression { id, .. }) = &*value.value else {
671 return (String::new(), false);
672 };
673
674 match id.as_str() {
675 "Mapped" => annotation_type(&value.slice),
676 "Optional" => {
677 let (inner, _) = annotation_type(&value.slice);
678 (inner, true)
679 }
680 value => (value.to_string(), false),
681 }
682 }
683 _ => (String::from("unknown"), false),
684 }
685}
686

Callers 1

extract_schemasFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected