Skip to content

Commit 78214bf

Browse files
committed
Remove unneeded duplicate check for pydantic v1 since we are already in
the else block.
1 parent 7f1a810 commit 78214bf

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

autogen/_pydantic.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,27 @@ def type2schema(t: Any) -> JsonSchemaValue:
6464
Returns:
6565
JsonSchemaValue: The JSON schema
6666
"""
67-
if PYDANTIC_V1:
68-
if t is None:
69-
return {"type": "null"}
70-
elif get_origin(t) is Union:
71-
return {"anyOf": [type2schema(tt) for tt in get_args(t)]}
72-
elif get_origin(t) in [Tuple, tuple]:
73-
prefixItems = [type2schema(tt) for tt in get_args(t)]
74-
return {
75-
"maxItems": len(prefixItems),
76-
"minItems": len(prefixItems),
77-
"prefixItems": prefixItems,
78-
"type": "array",
79-
}
80-
81-
d = schema_of(t)
82-
if "title" in d:
83-
d.pop("title")
84-
if "description" in d:
85-
d.pop("description")
86-
87-
return d
67+
68+
if t is None:
69+
return {"type": "null"}
70+
elif get_origin(t) is Union:
71+
return {"anyOf": [type2schema(tt) for tt in get_args(t)]}
72+
elif get_origin(t) in [Tuple, tuple]:
73+
prefixItems = [type2schema(tt) for tt in get_args(t)]
74+
return {
75+
"maxItems": len(prefixItems),
76+
"minItems": len(prefixItems),
77+
"prefixItems": prefixItems,
78+
"type": "array",
79+
}
80+
else:
81+
d = schema_of(t)
82+
if "title" in d:
83+
d.pop("title")
84+
if "description" in d:
85+
d.pop("description")
86+
87+
return d
8888

8989
def model_dump(model: BaseModel) -> Dict[str, Any]:
9090
"""Convert a pydantic model to a dict

0 commit comments

Comments
 (0)