@@ -171,7 +171,7 @@ def __from_schema(
171171 def _recurse () -> st .SearchStrategy [JSONType ]:
172172 _ , resolved = resolver .resolve (ref ) # type: ignore
173173 return from_schema (
174- resolved , custom_formats = custom_formats , resolver = resolver
174+ deepcopy ( resolved ) , custom_formats = custom_formats , resolver = resolver
175175 )
176176
177177 return st .deferred (_recurse )
@@ -462,16 +462,14 @@ def array_schema(
462462 if max_size is not None :
463463 max_size -= len (items )
464464
465- items_strats = [_from_schema_ (s ) for s in deepcopy ( items ) ]
465+ items_strats = [_from_schema_ (s ) for s in items ]
466466 additional_items_strat = _from_schema_ (additional_items )
467467
468468 # If we have a contains schema to satisfy, we try generating from it when
469469 # allowed to do so. We'll skip the None (unmergable / no contains) cases
470470 # below, and let Hypothesis ignore the FALSEY cases for us.
471471 if "contains" in schema :
472- for i , mrgd in enumerate (
473- merged ([schema ["contains" ], s ]) for s in deepcopy (items )
474- ):
472+ for i , mrgd in enumerate (merged ([schema ["contains" ], s ]) for s in items ):
475473 if mrgd is not None :
476474 items_strats [i ] |= _from_schema_ (mrgd )
477475 contains_additional = merged ([schema ["contains" ], additional_items ])
@@ -508,10 +506,10 @@ def not_seen(elem: JSONType) -> bool:
508506 st .lists (additional_items_strat , min_size = min_size , max_size = max_size ),
509507 )
510508 else :
511- items_strat = _from_schema_ (deepcopy ( items ) )
509+ items_strat = _from_schema_ (items )
512510 if "contains" in schema :
513511 contains_strat = _from_schema_ (schema ["contains" ])
514- if merged ([deepcopy ( items ) , schema ["contains" ]]) != schema ["contains" ]:
512+ if merged ([items , schema ["contains" ]]) != schema ["contains" ]:
515513 # We only need this filter if we couldn't merge items in when
516514 # canonicalising. Note that for list-items, above, we just skip
517515 # the mixed generation in this case (because they tend to be
@@ -548,7 +546,7 @@ def object_schema(
548546 return st .builds (dict )
549547 names ["type" ] = "string"
550548
551- properties = deepcopy ( schema .get ("properties" , {}) ) # exact name: value schema
549+ properties = schema .get ("properties" , {}) # exact name: value schema
552550 patterns = schema .get ("patternProperties" , {}) # regex for names: value schema
553551 # schema for other values; handled specially if nothing matches
554552 additional = schema .get ("additionalProperties" , {})
@@ -609,7 +607,7 @@ def from_object_schema(draw: Any) -> Any:
609607 if re .search (rgx , string = key ) is not None
610608 ]
611609 if key in properties :
612- pattern_schemas .insert (0 , deepcopy ( properties [key ]) )
610+ pattern_schemas .insert (0 , properties [key ])
613611
614612 if pattern_schemas :
615613 out [key ] = draw (
@@ -618,9 +616,7 @@ def from_object_schema(draw: Any) -> Any:
618616 else :
619617 out [key ] = draw (
620618 from_schema (
621- deepcopy (additional ),
622- custom_formats = custom_formats ,
623- resolver = resolver ,
619+ additional , custom_formats = custom_formats , resolver = resolver ,
624620 )
625621 )
626622
0 commit comments