@@ -67,16 +67,12 @@ fn serde_value_from_list(_gil: Python<'_>, bind_value: &Bound<'_, PyAny>) -> PSQ
6767 let mut result_vec: Vec < Value > = Vec :: with_capacity ( py_list. len ( ) ) ;
6868
6969 for item in py_list. iter ( ) {
70- if item. is_instance_of :: < PyDict > ( ) {
71- let python_dto = from_python_untyped ( & item) ?;
72- result_vec. push ( python_dto. to_serde_value ( ) ?) ;
73- } else if item. is_instance_of :: < PyList > ( ) {
70+ if item. is_instance_of :: < PyList > ( ) {
7471 let serde_value = build_serde_value ( & item) ?;
7572 result_vec. push ( serde_value) ;
7673 } else {
77- return Err ( RustPSQLDriverError :: PyToRustValueConversionError (
78- "Items in JSON array must be dicts or lists." . to_string ( ) ,
79- ) ) ;
74+ let python_dto = from_python_untyped ( & item) ?;
75+ result_vec. push ( python_dto. to_serde_value ( ) ?) ;
8076 }
8177 }
8278
@@ -112,17 +108,17 @@ fn serde_value_from_dict(bind_value: &Bound<'_, PyAny>) -> PSQLPyResult<Value> {
112108/// # Errors
113109/// May return error if cannot convert Python type into Rust one.
114110#[ allow( clippy:: needless_pass_by_value) ]
111+ #[ allow( clippy:: needless_return) ]
115112pub fn build_serde_value ( value : & Bound < ' _ , PyAny > ) -> PSQLPyResult < Value > {
116113 Python :: with_gil ( |gil| {
117114 if value. is_instance_of :: < PyList > ( ) {
118- serde_value_from_list ( gil, value)
115+ return serde_value_from_list ( gil, value) ;
119116 } else if value. is_instance_of :: < PyDict > ( ) {
120117 return serde_value_from_dict ( value) ;
121- } else {
122- return Err ( RustPSQLDriverError :: PyToRustValueConversionError (
123- "PyJSON must be dict value." . to_string ( ) ,
124- ) ) ;
125118 }
119+ Err ( RustPSQLDriverError :: PyToRustValueConversionError (
120+ "PyJSON must be dict or list value." . to_string ( ) ,
121+ ) )
126122 } )
127123}
128124
0 commit comments