Skip to content

Commit e27cae0

Browse files
Append refs outside rec
1 parent 10144b0 commit e27cae0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/schema_traverse.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use std::collections::HashMap;
21
use crate::tools::py_err;
32
use pyo3::exceptions::{PyKeyError, PyValueError};
43
use pyo3::prelude::*;
54
use pyo3::types::{PyDict, PyList, PySet, PyString, PyTuple};
65
use pyo3::{intern, Bound, PyResult};
6+
use std::collections::HashMap;
77

88
const CORE_SCHEMA_METADATA_DISCRIMINATOR_PLACEHOLDER_KEY: &str = "pydantic.internal.union_discriminator";
99

@@ -39,10 +39,9 @@ fn gather_definition_ref(schema_ref_dict: &Bound<'_, PyDict>, ctx: &mut GatherCt
3939
if let Some(schema_ref) = get!(schema_ref_dict, "schema_ref") {
4040
let schema_ref_pystr = schema_ref.downcast_exact::<PyString>()?;
4141
let schema_ref_str = schema_ref_pystr.to_str()?;
42+
defaultdict_list_append!(&ctx.def_refs, schema_ref_pystr, schema_ref_dict);
4243

4344
if *ctx.refs_recursion_count.entry(schema_ref_str.to_string()).or_insert(0) == 0 {
44-
defaultdict_list_append!(&ctx.def_refs, schema_ref_pystr, schema_ref_dict);
45-
4645
if let Some(def) = ctx.definitions_dict.get_item(schema_ref_pystr)? {
4746
*ctx.refs_recursion_count.get_mut(schema_ref_str).unwrap() += 1;
4847
gather_schema(def.downcast_exact::<PyDict>()?, ctx)?;

0 commit comments

Comments
 (0)