@@ -464,6 +464,14 @@ def array_schema(
464464 if contains_additional is not None :
465465 additional_items_strat |= _from_schema_ (contains_additional )
466466
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+
467475 if unique :
468476
469477 @st .composite # type: ignore
@@ -477,6 +485,8 @@ def not_seen(elem: JSONType) -> bool:
477485 for strat in items_strats :
478486 elems .append (draw (strat .filter (not_seen )))
479487 seen .add (encode_canonical_json (elems [- 1 ]))
488+ if max_size == 0 :
489+ return elems
480490 extra_items = st .lists (
481491 additional_items_strat .filter (not_seen ),
482492 min_size = min_size ,
@@ -487,6 +497,8 @@ def not_seen(elem: JSONType) -> bool:
487497 return elems + more_elems
488498
489499 strat = compose_lists_with_filter ()
500+ elif max_size == 0 :
501+ strat = st .tuples (* items_strats ).map (list )
490502 else :
491503 strat = st .builds (
492504 operator .add ,
@@ -504,7 +516,9 @@ def not_seen(elem: JSONType) -> bool:
504516 # heterogeneous) and hope it works out anyway.
505517 contains_strat = contains_strat .filter (make_validator (items ).is_valid )
506518 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 )
508522 strat = st .lists (
509523 items_strat ,
510524 min_size = min_size ,
0 commit comments