in serde-generate/src/python3.rs [140:183]
fn quote_type(&self, format: &Format) -> String {
use Format::*;
match format {
TypeName(x) => self.quote_qualified_name(x),
Unit => "st.unit".into(),
Bool => "bool".into(),
I8 => "st.int8".into(),
I16 => "st.int16".into(),
I32 => "st.int32".into(),
I64 => "st.int64".into(),
I128 => "st.int128".into(),
U8 => "st.uint8".into(),
U16 => "st.uint16".into(),
U32 => "st.uint32".into(),
U64 => "st.uint64".into(),
U128 => "st.uint128".into(),
F32 => "st.float32".into(),
F64 => "st.float64".into(),
Char => "st.char".into(),
Str => "str".into(),
Bytes => "bytes".into(),
Option(format) => format!("typing.Optional[{}]", self.quote_type(format)),
Seq(format) => format!("typing.Sequence[{}]", self.quote_type(format)),
Map { key, value } => format!(
"typing.Dict[{}, {}]",
self.quote_type(key),
self.quote_type(value)
),
Tuple(formats) => {
if formats.is_empty() {
"typing.Tuple[()]".into()
} else {
format!("typing.Tuple[{}]", self.quote_types(formats))
}
}
TupleArray { content, size } => format!(
"typing.Tuple[{}]",
self.quote_types(&vec![content.as_ref().clone(); *size])
), // Sadly, there are no fixed-size arrays in python.
Variable(_) => panic!("unexpected value"),
}
}