@@ -171,7 +171,7 @@ def __from_schema(
171
171
def _recurse () -> st .SearchStrategy [JSONType ]:
172
172
_ , resolved = resolver .resolve (ref ) # type: ignore
173
173
return from_schema (
174
- resolved , custom_formats = custom_formats , resolver = resolver
174
+ deepcopy ( resolved ) , custom_formats = custom_formats , resolver = resolver
175
175
)
176
176
177
177
return st .deferred (_recurse )
@@ -462,16 +462,14 @@ def array_schema(
462
462
if max_size is not None :
463
463
max_size -= len (items )
464
464
465
- items_strats = [_from_schema_ (s ) for s in deepcopy ( items ) ]
465
+ items_strats = [_from_schema_ (s ) for s in items ]
466
466
additional_items_strat = _from_schema_ (additional_items )
467
467
468
468
# If we have a contains schema to satisfy, we try generating from it when
469
469
# allowed to do so. We'll skip the None (unmergable / no contains) cases
470
470
# below, and let Hypothesis ignore the FALSEY cases for us.
471
471
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 ):
475
473
if mrgd is not None :
476
474
items_strats [i ] |= _from_schema_ (mrgd )
477
475
contains_additional = merged ([schema ["contains" ], additional_items ])
@@ -508,10 +506,10 @@ def not_seen(elem: JSONType) -> bool:
508
506
st .lists (additional_items_strat , min_size = min_size , max_size = max_size ),
509
507
)
510
508
else :
511
- items_strat = _from_schema_ (deepcopy ( items ) )
509
+ items_strat = _from_schema_ (items )
512
510
if "contains" in schema :
513
511
contains_strat = _from_schema_ (schema ["contains" ])
514
- if merged ([deepcopy ( items ) , schema ["contains" ]]) != schema ["contains" ]:
512
+ if merged ([items , schema ["contains" ]]) != schema ["contains" ]:
515
513
# We only need this filter if we couldn't merge items in when
516
514
# canonicalising. Note that for list-items, above, we just skip
517
515
# the mixed generation in this case (because they tend to be
@@ -548,7 +546,7 @@ def object_schema(
548
546
return st .builds (dict )
549
547
names ["type" ] = "string"
550
548
551
- properties = deepcopy ( schema .get ("properties" , {}) ) # exact name: value schema
549
+ properties = schema .get ("properties" , {}) # exact name: value schema
552
550
patterns = schema .get ("patternProperties" , {}) # regex for names: value schema
553
551
# schema for other values; handled specially if nothing matches
554
552
additional = schema .get ("additionalProperties" , {})
@@ -609,7 +607,7 @@ def from_object_schema(draw: Any) -> Any:
609
607
if re .search (rgx , string = key ) is not None
610
608
]
611
609
if key in properties :
612
- pattern_schemas .insert (0 , deepcopy ( properties [key ]) )
610
+ pattern_schemas .insert (0 , properties [key ])
613
611
614
612
if pattern_schemas :
615
613
out [key ] = draw (
@@ -618,9 +616,7 @@ def from_object_schema(draw: Any) -> Any:
618
616
else :
619
617
out [key ] = draw (
620
618
from_schema (
621
- deepcopy (additional ),
622
- custom_formats = custom_formats ,
623
- resolver = resolver ,
619
+ additional , custom_formats = custom_formats , resolver = resolver ,
624
620
)
625
621
)
626
622
0 commit comments