diff --git a/pyproject.toml b/pyproject.toml index b811005..4b282e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,6 @@ classifiers = [ "Programming Language :: Python :: 3 :: Only", ] dependencies = [ - "click>=8,<=8.2; python_version == '3.10'", # cannot deepcopy cmd params (specifically, Sentinel.UNSET) on 3.10 "click>=8,!=8.3.0,<8.4", "tomli; python_version < '3.11'", "colorama; platform_system == 'Windows'", diff --git a/spin/cmds/util.py b/spin/cmds/util.py index 1b8ae35..e49c8be 100644 --- a/spin/cmds/util.py +++ b/spin/cmds/util.py @@ -3,6 +3,7 @@ ) import copy +import enum import os import shlex import shutil @@ -159,6 +160,14 @@ def build(*, parent_callback, extra=None, **kwargs): """ my_cmd = copy.copy(cmd) + # This patch is to work around an enum deepcopy bug in Python 3.10. + if not hasattr(enum.Enum, "__deepcopy__"): + + def __deepcopy__(self, memo): + return self + + enum.Enum.__deepcopy__ = __deepcopy__ # type: ignore[method-assign] + # This is necessary to ensure that added options do not leak # to the original command my_cmd.params = copy.deepcopy(cmd.params)