1818
1919class MyPydanticModel (BaseModel ):
2020 ip_field : IPv4Address
21+ timedelta_field : timedelta
2122 string_field_assigned_field : str = Field ()
2223 string_field_with_default : str = Field (default_factory = lambda : "my-string" )
2324 annotated_list_of_str : Annotated [
@@ -27,6 +28,8 @@ class MyPydanticModel(BaseModel):
2728
2829 def _check_instance (self ):
2930 assert isinstance (self .ip_field , IPv4Address )
31+ assert isinstance (self .timedelta_field , timedelta )
32+ assert self .timedelta_field == timedelta (1 , 2 , 3 , 4 , 5 , 6 , 7 )
3033 assert isinstance (self .string_field_assigned_field , str )
3134 assert isinstance (self .string_field_with_default , str )
3235 assert isinstance (self .annotated_list_of_str , list )
@@ -107,6 +110,7 @@ def make_homogeneous_list_of_pydantic_objects() -> List[MyPydanticModel]:
107110 return [
108111 MyPydanticModel (
109112 ip_field = IPv4Address ("127.0.0.1" ),
113+ timedelta_field = timedelta (1 , 2 , 3 , 4 , 5 , 6 , 7 ),
110114 string_field_assigned_field = "my-string" ,
111115 annotated_list_of_str = ["my-string-1" , "my-string-2" ],
112116 str_short_sequence = ["my-string-1" , "my-string-2" ],
@@ -120,6 +124,7 @@ def make_heterogenous_list_of_pydantic_objects() -> (
120124 return [
121125 MyPydanticModel (
122126 ip_field = IPv4Address ("127.0.0.1" ),
127+ timedelta_field = timedelta (1 , 2 , 3 , 4 , 5 , 6 , 7 ),
123128 string_field_assigned_field = "my-string" ,
124129 annotated_list_of_str = ["my-string-1" , "my-string-2" ],
125130 str_short_sequence = ["my-string-1" , "my-string-2" ],
0 commit comments