@@ -10,7 +10,7 @@ def create_new_model_cast_doclist_to_list(model: Any) -> BaseDoc:
1010
1111 This can be needed because of this limitation of Pydantic:
1212
13- ( https://docs. pydantic.dev/latest/blog/ pydantic-v2/)
13+ https://github.com/ pydantic/ pydantic/issues/1457
1414
1515 ---
1616
@@ -30,7 +30,7 @@ class MyDoc(BaseDoc):
3030
3131 ---
3232 :param model: The input model
33- :return: A BaseDoc class dynamically created with List instead of DocList in the schema.
33+ :return: A new subclass of BaseDoc, where every DocList type in the schema is replaced by List .
3434 """
3535 fields : Dict [str , Any ] = {}
3636 for field_name , field in model .__annotations__ .items ():
@@ -48,12 +48,12 @@ class MyDoc(BaseDoc):
4848
4949
5050def _get_field_type_from_schema (
51- field_schema : Dict [str , Any ],
52- field_name : str ,
53- root_schema : Dict [str , Any ],
54- cached_models : Dict [str , Any ],
55- is_tensor : bool = False ,
56- num_recursions : int = 0 ,
51+ field_schema : Dict [str , Any ],
52+ field_name : str ,
53+ root_schema : Dict [str , Any ],
54+ cached_models : Dict [str , Any ],
55+ is_tensor : bool = False ,
56+ num_recursions : int = 0 ,
5757) -> type :
5858 """
5959 Private method used to extract the corresponding field type from the schema.
@@ -179,16 +179,17 @@ def _get_field_type_from_schema(
179179
180180
181181def create_base_doc_from_schema (
182- schema : Dict [str , Any ], base_doc_name : str , cached_models : Optional [Dict ] = None
182+ schema : Dict [str , Any ], base_doc_name : str , cached_models : Optional [Dict ] = None
183183) -> Type :
184184 """
185- Dynamically create a `BaseDoc` class from a `schema` of another `BaseDoc`.
185+ Dynamically create a `BaseDoc` subclass from a `schema` of another `BaseDoc`.
186+
186187 This method is intended to dynamically create a `BaseDoc` compatible with the schema
187- of another BaseDoc that is not available in the context . For instance, you may have stored the schema
188- as a JSON, or sent it to another service, etc .. .
188+ of another BaseDoc. This is useful when that other `BaseDoc` is not available in the current scope . For instance, you may have stored the schema
189+ as a JSON, or sent it to another service, etc.
189190
190- Due to this Pydantic limitation (https://docs. pydantic.dev/latest/blog/ pydantic-v2/ ), we need to make sure that the
191- input schema uses `List` and not `DocList`, therefore this is recommended to be used in combination with `create_new_model_cast_doclist_to_list`
191+ Due to this Pydantic limitation (https://github.com/ pydantic/ pydantic/issues/1457 ), we need to make sure that the
192+ input schema uses `List` and not `DocList`. Therefore this is recommended to be used in combination with `create_new_model_cast_doclist_to_list`
192193 to make sure that `DocLists` in schema are converted to `List`.
193194
194195 ---
0 commit comments