Skip to content

Commit 493038b

Browse files
authored
Patch in enum deepcopy on Python 3.10 (#312)
1 parent 481c66f commit 493038b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ classifiers = [
2323
"Programming Language :: Python :: 3 :: Only",
2424
]
2525
dependencies = [
26-
"click>=8,<=8.2; python_version == '3.10'", # cannot deepcopy cmd params (specifically, Sentinel.UNSET) on 3.10
2726
"click>=8,!=8.3.0,<8.4",
2827
"tomli; python_version < '3.11'",
2928
"colorama; platform_system == 'Windows'",

spin/cmds/util.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
)
44

55
import copy
6+
import enum
67
import os
78
import shlex
89
import shutil
@@ -159,6 +160,14 @@ def build(*, parent_callback, extra=None, **kwargs):
159160
"""
160161
my_cmd = copy.copy(cmd)
161162

163+
# This patch is to work around an enum deepcopy bug in Python 3.10.
164+
if not hasattr(enum.Enum, "__deepcopy__"):
165+
166+
def __deepcopy__(self, memo):
167+
return self
168+
169+
enum.Enum.__deepcopy__ = __deepcopy__ # type: ignore[method-assign]
170+
162171
# This is necessary to ensure that added options do not leak
163172
# to the original command
164173
my_cmd.params = copy.deepcopy(cmd.params)

0 commit comments

Comments
 (0)