Skip to content

Commit 20c17bf

Browse files
Clean up
1 parent f2b4fc2 commit 20c17bf

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/schema_traverse.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ macro_rules! traverse_key_fn {
2424
macro_rules! traverse {
2525
($($key:expr => $func:expr),*; $dict: expr, $ctx: expr) => {{
2626
$(traverse_key_fn!($key, $func, $dict, $ctx);)*
27-
gather_serialization($dict, $ctx)?;
28-
gather_meta($dict, $ctx)?;
27+
traverse_key_fn!("serialization", gather_serialization, $dict, $ctx);
28+
gather_meta($dict, $ctx)
2929
}}
3030
}
3131

@@ -56,7 +56,7 @@ fn gather_definition_ref(schema_ref_dict: &Bound<'_, PyDict>, ctx: &mut GatherCt
5656
ctx.recursively_seen_refs.insert(schema_ref_str.to_string());
5757

5858
gather_schema(definition.downcast_exact::<PyDict>()?, ctx)?;
59-
gather_serialization(schema_ref_dict, ctx)?;
59+
traverse_key_fn!("serialization", gather_serialization, schema_ref_dict, ctx);
6060
gather_meta(schema_ref_dict, ctx)?;
6161

6262
ctx.recursively_seen_refs.remove(schema_ref_str);
@@ -75,11 +75,7 @@ fn gather_definition_ref(schema_ref_dict: &Bound<'_, PyDict>, ctx: &mut GatherCt
7575
}
7676

7777
fn gather_serialization(schema: &Bound<'_, PyDict>, ctx: &mut GatherCtx) -> PyResult<()> {
78-
if let Some(ser) = get!(schema, "serialization") {
79-
let ser_dict = ser.downcast_exact::<PyDict>()?;
80-
traverse!("schema" => gather_schema, "return_schema" => gather_schema; ser_dict, ctx);
81-
}
82-
Ok(())
78+
traverse!("schema" => gather_schema, "return_schema" => gather_schema; schema, ctx)
8379
}
8480

8581
fn gather_meta(schema: &Bound<'_, PyDict>, ctx: &mut GatherCtx) -> PyResult<()> {
@@ -133,7 +129,7 @@ fn gather_schema(schema: &Bound<'_, PyDict>, ctx: &mut GatherCtx) -> PyResult<()
133129
return py_err!(PyKeyError; "Schema type missing");
134130
}
135131
match type_.unwrap().downcast_exact::<PyString>()?.to_str()? {
136-
"definition-ref" => gather_definition_ref(schema, ctx)?,
132+
"definition-ref" => gather_definition_ref(schema, ctx),
137133
"definitions" => traverse!("schema" => gather_schema, "definitions" => gather_list; schema, ctx),
138134
"list" | "set" | "frozenset" | "generator" => traverse!("items_schema" => gather_schema; schema, ctx),
139135
"tuple" => traverse!("items_schema" => gather_list; schema, ctx),
@@ -157,8 +153,7 @@ fn gather_schema(schema: &Bound<'_, PyDict>, ctx: &mut GatherCtx) -> PyResult<()
157153
"computed-field" | "function-plain" => traverse!("return_schema" => gather_schema; schema, ctx),
158154
"function-wrap" => traverse!("return_schema" => gather_schema, "schema" => gather_schema; schema, ctx),
159155
_ => traverse!("schema" => gather_schema; schema, ctx),
160-
};
161-
Ok(())
156+
}
162157
}
163158

164159
pub struct GatherCtx<'a, 'py> {

0 commit comments

Comments
 (0)