Skip to content

Commit

Permalink
Moving deepcopy of defaults to prevent pickle issue during parse_args
Browse files Browse the repository at this point in the history
  • Loading branch information
swansonk14 committed Jun 28, 2023
1 parent 7f12646 commit 33e7c53
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tap/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def _add_argument(self, *name_or_flags, **kwargs) -> None:

# Get default if not specified
if hasattr(self, variable):
kwargs['default'] = kwargs.get('default', getattr(self, variable))
# Deepcopy to prevent mutation of default values
kwargs['default'] = deepcopy(kwargs.get('default', getattr(self, variable)))

# Set required if option arg
if (
Expand Down Expand Up @@ -456,8 +457,8 @@ def parse_args(self: TapType,
elif var_type in (Tuple, tuple):
value = tuple(value)

# Set variable in self (and deepcopy to prevent mutation of default values)
setattr(self, variable, deepcopy(value))
# Set variable in self
setattr(self, variable, value)

# Process args
self.process_args()
Expand Down

0 comments on commit 33e7c53

Please sign in to comment.