File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -3383,9 +3383,15 @@ def __init__(
33833383 type_origin = get_origin (annotated_type ) or annotated_type
33843384
33853385 if self .default is MISSING and self .default_factory is None :
3386- self . default = types .get_default_value_for_type (annotated_type )
3387- if self . default is None and not types .is_optional (annotated_type ):
3386+ default_value = types .get_default_value_for_type (annotated_type )
3387+ if default_value is None and not types .is_optional (annotated_type ):
33883388 annotated_type = annotated_type | None
3389+ if types .is_immutable (default_value ):
3390+ self .default = default_value
3391+ else :
3392+ self .default_factory = functools .partial (
3393+ copy .deepcopy , default_value
3394+ )
33893395 self .outer_type_ = self .annotated_type = annotated_type
33903396
33913397 if type_origin is Annotated :
You can’t perform that action at this time.
0 commit comments