@@ -326,7 +326,13 @@ def test_recursion_branch():
326326 'loc' : ('branch' ,),
327327 'msg' : 'Recursion error - cyclic reference detected' ,
328328 'input' : {'name' : 'recursive' , 'branch' : IsPartialDict (name = 'recursive' )},
329- }
329+ },
330+ {
331+ 'type' : 'none_required' ,
332+ 'loc' : ('branch' ,),
333+ 'msg' : 'Input should be None' ,
334+ 'input' : {'name' : 'recursive' , 'branch' : IsPartialDict (name = 'recursive' )},
335+ },
330336 ]
331337
332338
@@ -375,7 +381,13 @@ def test_recursion_branch_from_attributes():
375381 'loc' : ('branch' ,),
376382 'msg' : 'Recursion error - cyclic reference detected' ,
377383 'input' : HasAttributes (name = 'root' , branch = AnyThing ()),
378- }
384+ },
385+ {
386+ 'type' : 'none_required' ,
387+ 'loc' : ('branch' ,),
388+ 'msg' : 'Input should be None' ,
389+ 'input' : HasAttributes (name = 'root' , branch = AnyThing ()),
390+ },
379391 ]
380392
381393
@@ -475,12 +487,30 @@ def test_multiple_tuple_recursion(multiple_tuple_schema: SchemaValidator):
475487 'msg' : 'Recursion error - cyclic reference detected' ,
476488 'input' : [1 , IsList (length = 2 )],
477489 },
490+ {
491+ 'type' : 'none_required' ,
492+ 'loc' : ('f1' , 1 ),
493+ 'msg' : 'Input should be None' ,
494+ 'input' : [1 , IsList (length = 2 )],
495+ },
478496 {
479497 'type' : 'recursion_loop' ,
480498 'loc' : ('f2' , 1 ),
481499 'msg' : 'Recursion error - cyclic reference detected' ,
482500 'input' : [1 , IsList (length = 2 )],
483501 },
502+ {
503+ 'type' : 'none_required' ,
504+ 'loc' : ('f2' , 1 ),
505+ 'msg' : 'Input should be None' ,
506+ 'input' : [1 , IsList (length = 2 )],
507+ },
508+ {
509+ 'type' : 'none_required' ,
510+ 'loc' : ('f2' ,),
511+ 'msg' : 'Input should be None' ,
512+ 'input' : [1 , IsList (length = 2 )],
513+ },
484514 ]
485515
486516
@@ -497,12 +527,30 @@ def test_multiple_tuple_recursion_once(multiple_tuple_schema: SchemaValidator):
497527 'msg' : 'Recursion error - cyclic reference detected' ,
498528 'input' : [1 , IsList (length = 2 )],
499529 },
530+ {
531+ 'type' : 'none_required' ,
532+ 'loc' : ('f1' , 1 ),
533+ 'msg' : 'Input should be None' ,
534+ 'input' : [1 , IsList (length = 2 )],
535+ },
500536 {
501537 'type' : 'recursion_loop' ,
502538 'loc' : ('f2' , 1 ),
503539 'msg' : 'Recursion error - cyclic reference detected' ,
504540 'input' : [1 , IsList (length = 2 )],
505541 },
542+ {
543+ 'type' : 'none_required' ,
544+ 'loc' : ('f2' , 1 ),
545+ 'msg' : 'Input should be None' ,
546+ 'input' : [1 , IsList (length = 2 )],
547+ },
548+ {
549+ 'type' : 'none_required' ,
550+ 'loc' : ('f2' ,),
551+ 'msg' : 'Input should be None' ,
552+ 'input' : [1 , IsList (length = 2 )],
553+ },
506554 ]
507555
508556
@@ -539,7 +587,13 @@ def wrap_func(input_value, validator, info):
539587 'loc' : (1 ,),
540588 'msg' : 'Recursion error - cyclic reference detected' ,
541589 'input' : IsList (positions = {0 : 1 }, length = 2 ),
542- }
590+ },
591+ {
592+ 'type' : 'none_required' ,
593+ 'loc' : (1 ,),
594+ 'msg' : 'Input should be None' ,
595+ 'input' : IsList (positions = {0 : 1 }, length = 2 ),
596+ },
543597 ]
544598
545599
@@ -927,7 +981,19 @@ def test_cyclic_data() -> None:
927981 'loc' : ('b' , 'a' ),
928982 'msg' : 'Recursion error - cyclic reference detected' ,
929983 'input' : cyclic_data ,
930- }
984+ },
985+ {
986+ 'type' : 'none_required' ,
987+ 'loc' : ('b' , 'a' ),
988+ 'msg' : 'Input should be None' ,
989+ 'input' : cyclic_data ,
990+ },
991+ {
992+ 'type' : 'none_required' ,
993+ 'loc' : ('b' ,),
994+ 'msg' : 'Input should be None' ,
995+ 'input' : cyclic_data ['b' ],
996+ },
931997 ]
932998
933999
@@ -977,7 +1043,25 @@ def test_cyclic_data_threeway() -> None:
9771043 'loc' : ('b' , 'c' , 'a' ),
9781044 'msg' : 'Recursion error - cyclic reference detected' ,
9791045 'input' : cyclic_data ,
980- }
1046+ },
1047+ {
1048+ 'type' : 'none_required' ,
1049+ 'loc' : ('b' , 'c' , 'a' ),
1050+ 'msg' : 'Input should be None' ,
1051+ 'input' : cyclic_data ,
1052+ },
1053+ {
1054+ 'type' : 'none_required' ,
1055+ 'loc' : ('b' , 'c' ),
1056+ 'msg' : 'Input should be None' ,
1057+ 'input' : cyclic_data ['b' ]['c' ],
1058+ },
1059+ {
1060+ 'type' : 'none_required' ,
1061+ 'loc' : ('b' ,),
1062+ 'msg' : 'Input should be None' ,
1063+ 'input' : cyclic_data ['b' ],
1064+ },
9811065 ]
9821066
9831067
@@ -1051,6 +1135,12 @@ def test_complex_recursive_type() -> None:
10511135 'msg' : 'Input should be a valid boolean' ,
10521136 'input' : datetime .date (1992 , 12 , 11 ),
10531137 },
1138+ {
1139+ 'type' : 'none_required' ,
1140+ 'loc' : ('dict[str,...]' , 'a' ),
1141+ 'msg' : 'Input should be None' ,
1142+ 'input' : datetime .date (1992 , 12 , 11 ),
1143+ },
10541144 {
10551145 'type' : 'string_type' ,
10561146 'loc' : ('str' ,),
@@ -1075,6 +1165,12 @@ def test_complex_recursive_type() -> None:
10751165 'msg' : 'Input should be a valid boolean' ,
10761166 'input' : {'a' : datetime .date (1992 , 12 , 11 )},
10771167 },
1168+ {
1169+ 'type' : 'none_required' ,
1170+ 'loc' : (),
1171+ 'msg' : 'Input should be None' ,
1172+ 'input' : {'a' : datetime .date (1992 , 12 , 11 )},
1173+ },
10781174 ]
10791175
10801176
0 commit comments