@@ -464,6 +464,14 @@ def array_schema(
464
464
if contains_additional is not None :
465
465
additional_items_strat |= _from_schema_ (contains_additional )
466
466
467
+ # Hypothesis raises InvalidArgument for empty elements and non-None
468
+ # max_size, because the user has asked for a possibility which will
469
+ # never happen... but we can work around that here.
470
+ if additional_items_strat .is_empty :
471
+ if min_size >= 1 :
472
+ return st .nothing ()
473
+ max_size = 0
474
+
467
475
if unique :
468
476
469
477
@st .composite # type: ignore
@@ -477,6 +485,8 @@ def not_seen(elem: JSONType) -> bool:
477
485
for strat in items_strats :
478
486
elems .append (draw (strat .filter (not_seen )))
479
487
seen .add (encode_canonical_json (elems [- 1 ]))
488
+ if max_size == 0 :
489
+ return elems
480
490
extra_items = st .lists (
481
491
additional_items_strat .filter (not_seen ),
482
492
min_size = min_size ,
@@ -487,6 +497,8 @@ def not_seen(elem: JSONType) -> bool:
487
497
return elems + more_elems
488
498
489
499
strat = compose_lists_with_filter ()
500
+ elif max_size == 0 :
501
+ strat = st .tuples (* items_strats ).map (list )
490
502
else :
491
503
strat = st .builds (
492
504
operator .add ,
@@ -504,7 +516,9 @@ def not_seen(elem: JSONType) -> bool:
504
516
# heterogeneous) and hope it works out anyway.
505
517
contains_strat = contains_strat .filter (make_validator (items ).is_valid )
506
518
items_strat |= contains_strat
507
-
519
+ elif items_strat .is_empty and min_size == 0 and max_size is not None :
520
+ # As above, work around a Hypothesis check for unsatisfiable max_size.
521
+ return st .builds (list )
508
522
strat = st .lists (
509
523
items_strat ,
510
524
min_size = min_size ,
0 commit comments