🔧 chore(util.py): add get_type_from_union_literal function to handle union literals in format_dict function
🔧 chore(util.py): add get_type_from_union_literal function to handle union literals in format_dict function
This commit is contained in:
parent
7929a43bc4
commit
591237c5dd
1 changed files with 9 additions and 0 deletions
|
|
@ -276,6 +276,7 @@ def format_dict(
|
|||
_type = remove_optional_wrapper(_type)
|
||||
_type = check_list_type(_type, value)
|
||||
_type = replace_mapping_with_dict(_type)
|
||||
_type = get_type_from_union_literal(_type)
|
||||
|
||||
value["type"] = get_formatted_type(key, _type)
|
||||
value["show"] = should_show_field(value, key)
|
||||
|
|
@ -462,3 +463,11 @@ def build_loader_repr_from_documents(documents: List[Document]) -> str:
|
|||
\nAvg. Document Length (characters): {int(avg_length)}
|
||||
Documents: {documents[:3]}..."""
|
||||
return "0 documents"
|
||||
|
||||
|
||||
def get_type_from_union_literal(union_literal: str) -> str:
|
||||
# if types are literal strings
|
||||
# the type is a string
|
||||
if "Literal" in union_literal:
|
||||
return "str"
|
||||
return union_literal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue