Skip to content

Commit e2d41f0

Browse files
Joan FontanalsJohannesMessner
andcommitted
docs: apply suggestions from code review
Co-authored-by: Johannes Messner <[email protected]> Signed-off-by: Joan Fontanals <[email protected]> Signed-off-by: Joan Fontanals Martinez <[email protected]>
1 parent f39cadb commit e2d41f0

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

docarray/utils/create.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

5050
def _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

181181
def 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 ### better link here, like above ### (https://docs.pydantic.dev/latest/blog/pydantic-v2/), 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

Comments
 (0)