Skip to content

Commit

Permalink
Update color.py (#2512)
Browse files Browse the repository at this point in the history
adds __getnewargs__() so Color can be un/pickled
  • Loading branch information
elegantiron authored Jan 25, 2025
1 parent 4cb0211 commit 458c20f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arcade/types/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def __new__(cls, r: int, g: int, b: int, a: int = 255):
# https://github.com/python/mypy/issues/8541
return super().__new__(cls, (r, g, b, a)) # type: ignore

def __getnewargs__(self) -> tuple[int, int, int, int]:
return self.r, self.g, self.b, self.a

def __deepcopy__(self, _) -> Self:
"""Allow :py:func:`~copy.deepcopy` to be used with Color"""
return self.__class__(r=self.r, g=self.g, b=self.b, a=self.a)
Expand Down

0 comments on commit 458c20f

Please sign in to comment.