diff --git a/crates/chia_py_streamable_macro/src/lib.rs b/crates/chia_py_streamable_macro/src/lib.rs index 4d41c60a9..4bff5d676 100644 --- a/crates/chia_py_streamable_macro/src/lib.rs +++ b/crates/chia_py_streamable_macro/src/lib.rs @@ -462,8 +462,32 @@ pub fn py_json_dict_macro(input: proc_macro::TokenStream) -> proc_macro::TokenSt } }); } + syn::Fields::Unnamed(FieldsUnnamed { unnamed, .. }) if unnamed.len() == 1 => { + let ftype: syn::Type = unnamed + .first() + .expect("match arm if requires 1 item") + .ty + .clone(); + + py_protocol.extend( quote! { + + impl #crate_name::to_json_dict::ToJsonDict for #ident { + fn to_json_dict(&self, py: pyo3::Python) -> pyo3::PyResult { + Ok(self.0.to_json_dict(py)?.into()) + } + } + + impl #crate_name::from_json_dict::FromJsonDict for #ident { + fn from_json_dict(o: &pyo3::Bound) -> pyo3::PyResult { + Ok(Self( + <#ftype as #crate_name::from_json_dict::FromJsonDict>::from_json_dict(&o)? + )) + } + } + }); + } _ => { - panic!("PyJsonDict only supports structs"); + panic!("PyJsonDict only supports named structs and single field unnamed structs"); } } diff --git a/wheel/stubtest.allowlist.3-11-plus b/wheel/stubtest.allowlist.3-11-plus index 68af7fc61..737a58e04 100644 --- a/wheel/stubtest.allowlist.3-11-plus +++ b/wheel/stubtest.allowlist.3-11-plus @@ -1,10 +1,6 @@ # TODO: ask stubtest/mypy about these as they seem unlikely to be our doing -chia_rs\.sized_byte_class\.TypeVar\.__bound__ -chia_rs\.sized_byte_class\.TypeVar\.__constraints__ -chia_rs\.sized_byte_class\.TypeVar\.__contravariant__ -chia_rs\.sized_byte_class\.TypeVar\.__covariant__ - -chia_rs\.struct_stream\.TypeVar\.__bound__ -chia_rs\.struct_stream\.TypeVar\.__constraints__ -chia_rs\.struct_stream\.TypeVar\.__contravariant__ -chia_rs\.struct_stream\.TypeVar\.__covariant__ +chia_rs\..*\.TypeVar\.__init__ +chia_rs\..*\.TypeVar\.__bound__ +chia_rs\..*\.TypeVar\.__constraints__ +chia_rs\..*\.TypeVar\.__contravariant__ +chia_rs\..*\.TypeVar\.__covariant__