11import datetime
2+ import inspect
23import uuid
34from dataclasses import dataclass , make_dataclass , field
45from typing import Annotated , Any , Callable , Literal , NamedTuple
@@ -236,19 +237,24 @@ def test_encode_engine_value_none() -> None:
236237
237238
238239def test_roundtrip_basic_types () -> None :
239- validate_full_roundtrip (b"hello world" , bytes , (b"hello world" , None ))
240+ validate_full_roundtrip (
241+ b"hello world" ,
242+ bytes ,
243+ (b"hello world" , inspect .Parameter .empty ),
244+ (b"hello world" , Any ),
245+ )
240246 validate_full_roundtrip (b"\x00 \x01 \x02 \xff \xfe " , bytes )
241- validate_full_roundtrip ("hello" , str , ("hello" , None ))
242- validate_full_roundtrip (True , bool , (True , None ))
243- validate_full_roundtrip (False , bool , (False , None ))
247+ validate_full_roundtrip ("hello" , str , ("hello" , Any ))
248+ validate_full_roundtrip (True , bool , (True , Any ))
249+ validate_full_roundtrip (False , bool , (False , Any ))
244250 validate_full_roundtrip (
245- 42 , cocoindex .Int64 , (42 , int ), (np .int64 (42 ), np .int64 ), (42 , None )
251+ 42 , cocoindex .Int64 , (42 , int ), (np .int64 (42 ), np .int64 ), (42 , Any )
246252 )
247253 validate_full_roundtrip (42 , int , (42 , cocoindex .Int64 ))
248254 validate_full_roundtrip (np .int64 (42 ), np .int64 , (42 , cocoindex .Int64 ))
249255
250256 validate_full_roundtrip (
251- 3.25 , Float64 , (3.25 , float ), (np .float64 (3.25 ), np .float64 ), (3.25 , None )
257+ 3.25 , Float64 , (3.25 , float ), (np .float64 (3.25 ), np .float64 ), (3.25 , Any )
252258 )
253259 validate_full_roundtrip (3.25 , float , (3.25 , Float64 ))
254260 validate_full_roundtrip (np .float64 (3.25 ), np .float64 , (3.25 , Float64 ))
@@ -260,35 +266,35 @@ def test_roundtrip_basic_types() -> None:
260266 (np .float32 (3.25 ), np .float32 ),
261267 (np .float64 (3.25 ), np .float64 ),
262268 (3.25 , Float64 ),
263- (3.25 , None ),
269+ (3.25 , Any ),
264270 )
265271 validate_full_roundtrip (np .float32 (3.25 ), np .float32 , (3.25 , Float32 ))
266272
267273
268274def test_roundtrip_uuid () -> None :
269275 uuid_value = uuid .uuid4 ()
270- validate_full_roundtrip (uuid_value , uuid .UUID , (uuid_value , None ))
276+ validate_full_roundtrip (uuid_value , uuid .UUID , (uuid_value , Any ))
271277
272278
273279def test_roundtrip_range () -> None :
274280 r1 = (0 , 100 )
275- validate_full_roundtrip (r1 , cocoindex .Range , (r1 , None ))
281+ validate_full_roundtrip (r1 , cocoindex .Range , (r1 , Any ))
276282 r2 = (50 , 50 )
277- validate_full_roundtrip (r2 , cocoindex .Range , (r2 , None ))
283+ validate_full_roundtrip (r2 , cocoindex .Range , (r2 , Any ))
278284 r3 = (0 , 1_000_000_000 )
279- validate_full_roundtrip (r3 , cocoindex .Range , (r3 , None ))
285+ validate_full_roundtrip (r3 , cocoindex .Range , (r3 , Any ))
280286
281287
282288def test_roundtrip_time () -> None :
283289 t1 = datetime .time (10 , 30 , 50 , 123456 )
284- validate_full_roundtrip (t1 , datetime .time , (t1 , None ))
290+ validate_full_roundtrip (t1 , datetime .time , (t1 , Any ))
285291 t2 = datetime .time (23 , 59 , 59 )
286- validate_full_roundtrip (t2 , datetime .time , (t2 , None ))
292+ validate_full_roundtrip (t2 , datetime .time , (t2 , Any ))
287293 t3 = datetime .time (0 , 0 , 0 )
288- validate_full_roundtrip (t3 , datetime .time , (t3 , None ))
294+ validate_full_roundtrip (t3 , datetime .time , (t3 , Any ))
289295
290296 validate_full_roundtrip (
291- datetime .date (2025 , 1 , 1 ), datetime .date , (datetime .date (2025 , 1 , 1 ), None )
297+ datetime .date (2025 , 1 , 1 ), datetime .date , (datetime .date (2025 , 1 , 1 ), Any )
292298 )
293299
294300 validate_full_roundtrip (
@@ -333,11 +339,11 @@ def test_roundtrip_timedelta() -> None:
333339 td1 = datetime .timedelta (
334340 days = 5 , seconds = 10 , microseconds = 123 , milliseconds = 456 , minutes = 30 , hours = 2
335341 )
336- validate_full_roundtrip (td1 , datetime .timedelta , (td1 , None ))
342+ validate_full_roundtrip (td1 , datetime .timedelta , (td1 , Any ))
337343 td2 = datetime .timedelta (days = - 5 , hours = - 2 )
338- validate_full_roundtrip (td2 , datetime .timedelta , (td2 , None ))
344+ validate_full_roundtrip (td2 , datetime .timedelta , (td2 , Any ))
339345 td3 = datetime .timedelta (0 )
340- validate_full_roundtrip (td3 , datetime .timedelta , (td3 , None ))
346+ validate_full_roundtrip (td3 , datetime .timedelta , (td3 , Any ))
341347
342348
343349def test_roundtrip_json () -> None :
@@ -1251,8 +1257,8 @@ class Config:
12511257 instance = Config ("localhost" , 8080 , True )
12521258 expected_dict = {"host" : "localhost" , "port" : 8080 , "debug" : True }
12531259
1254- # Test None annotation (should be treated as Any)
1255- validate_full_roundtrip (instance , Config , (expected_dict , None ))
1260+ # Test empty annotation (should be treated as Any)
1261+ validate_full_roundtrip (instance , Config , (expected_dict , inspect . Parameter . empty ))
12561262
12571263
12581264def test_roundtrip_struct_to_dict_nested () -> None :
0 commit comments