@@ -326,7 +326,13 @@ def test_recursion_branch():
326
326
'loc' : ('branch' ,),
327
327
'msg' : 'Recursion error - cyclic reference detected' ,
328
328
'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
+ },
330
336
]
331
337
332
338
@@ -375,7 +381,13 @@ def test_recursion_branch_from_attributes():
375
381
'loc' : ('branch' ,),
376
382
'msg' : 'Recursion error - cyclic reference detected' ,
377
383
'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
+ },
379
391
]
380
392
381
393
@@ -475,12 +487,30 @@ def test_multiple_tuple_recursion(multiple_tuple_schema: SchemaValidator):
475
487
'msg' : 'Recursion error - cyclic reference detected' ,
476
488
'input' : [1 , IsList (length = 2 )],
477
489
},
490
+ {
491
+ 'type' : 'none_required' ,
492
+ 'loc' : ('f1' , 1 ),
493
+ 'msg' : 'Input should be None' ,
494
+ 'input' : [1 , IsList (length = 2 )],
495
+ },
478
496
{
479
497
'type' : 'recursion_loop' ,
480
498
'loc' : ('f2' , 1 ),
481
499
'msg' : 'Recursion error - cyclic reference detected' ,
482
500
'input' : [1 , IsList (length = 2 )],
483
501
},
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
+ },
484
514
]
485
515
486
516
@@ -497,12 +527,30 @@ def test_multiple_tuple_recursion_once(multiple_tuple_schema: SchemaValidator):
497
527
'msg' : 'Recursion error - cyclic reference detected' ,
498
528
'input' : [1 , IsList (length = 2 )],
499
529
},
530
+ {
531
+ 'type' : 'none_required' ,
532
+ 'loc' : ('f1' , 1 ),
533
+ 'msg' : 'Input should be None' ,
534
+ 'input' : [1 , IsList (length = 2 )],
535
+ },
500
536
{
501
537
'type' : 'recursion_loop' ,
502
538
'loc' : ('f2' , 1 ),
503
539
'msg' : 'Recursion error - cyclic reference detected' ,
504
540
'input' : [1 , IsList (length = 2 )],
505
541
},
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
+ },
506
554
]
507
555
508
556
@@ -539,7 +587,13 @@ def wrap_func(input_value, validator, info):
539
587
'loc' : (1 ,),
540
588
'msg' : 'Recursion error - cyclic reference detected' ,
541
589
'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
+ },
543
597
]
544
598
545
599
@@ -927,7 +981,19 @@ def test_cyclic_data() -> None:
927
981
'loc' : ('b' , 'a' ),
928
982
'msg' : 'Recursion error - cyclic reference detected' ,
929
983
'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
+ },
931
997
]
932
998
933
999
@@ -977,7 +1043,25 @@ def test_cyclic_data_threeway() -> None:
977
1043
'loc' : ('b' , 'c' , 'a' ),
978
1044
'msg' : 'Recursion error - cyclic reference detected' ,
979
1045
'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
+ },
981
1065
]
982
1066
983
1067
@@ -1051,6 +1135,12 @@ def test_complex_recursive_type() -> None:
1051
1135
'msg' : 'Input should be a valid boolean' ,
1052
1136
'input' : datetime .date (1992 , 12 , 11 ),
1053
1137
},
1138
+ {
1139
+ 'type' : 'none_required' ,
1140
+ 'loc' : ('dict[str,...]' , 'a' ),
1141
+ 'msg' : 'Input should be None' ,
1142
+ 'input' : datetime .date (1992 , 12 , 11 ),
1143
+ },
1054
1144
{
1055
1145
'type' : 'string_type' ,
1056
1146
'loc' : ('str' ,),
@@ -1075,6 +1165,12 @@ def test_complex_recursive_type() -> None:
1075
1165
'msg' : 'Input should be a valid boolean' ,
1076
1166
'input' : {'a' : datetime .date (1992 , 12 , 11 )},
1077
1167
},
1168
+ {
1169
+ 'type' : 'none_required' ,
1170
+ 'loc' : (),
1171
+ 'msg' : 'Input should be None' ,
1172
+ 'input' : {'a' : datetime .date (1992 , 12 , 11 )},
1173
+ },
1078
1174
]
1079
1175
1080
1176
0 commit comments