1- from typing import Any , Dict , Generic , Type , TypeVar
1+ from typing import Any , Generic , TypeVar
22
33from pydantic import BaseModel
44from pydantic .version import VERSION as PYDANTIC_VERSION
1111Model = TypeVar ("Model" , bound = BaseModel )
1212
1313
14- def model_validate (model_class : Type [Model ], data : Dict [Any , Any ]) -> Model :
14+ def model_validate (model_class : type [Model ], data : dict [Any , Any ]) -> Model :
1515 if PYDANTIC_V2 :
1616 return model_class .model_validate (data ) # type: ignore[no-any-return, unused-ignore, attr-defined]
1717 else :
1818 return model_class .parse_obj (data ) # type: ignore[no-any-return, unused-ignore, attr-defined]
1919
2020
21- def model_validate_json (model_class : Type [Model ], data : str ) -> Model :
21+ def model_validate_json (model_class : type [Model ], data : str ) -> Model :
2222 if PYDANTIC_V2 :
2323 return model_class .model_validate_json (data ) # type: ignore[no-any-return, unused-ignore, attr-defined]
2424 else :
2525 return model_class .parse_raw (data ) # type: ignore[no-any-return, unused-ignore, attr-defined]
2626
2727
28- def model_dump (obj : BaseModel , ** kwargs : Any ) -> Dict [Any , Any ]:
28+ def model_dump (obj : BaseModel , ** kwargs : Any ) -> dict [Any , Any ]:
2929 if PYDANTIC_V2 :
3030 return obj .model_dump (** kwargs ) # type: ignore[no-any-return, unused-ignore, attr-defined]
3131 else :
@@ -41,7 +41,7 @@ def model_dump_json(obj: BaseModel) -> str:
4141
4242
4343class TypeAdapter (Generic [T ]):
44- def __init__ (self , type_ : Type [T ]) -> None :
44+ def __init__ (self , type_ : type [T ]) -> None :
4545 self .type_ = type_
4646
4747 if PYDANTIC_V2 :
0 commit comments