masque/masque/traits/copyable.py
2023-10-15 16:18:33 -07:00

32 lines
585 B
Python

from typing import Self
from abc import ABCMeta
import copy
class Copyable(metaclass=ABCMeta):
"""
Trait class which adds .copy() and .deepcopy()
"""
__slots__ = ()
#
# Non-abstract methods
#
def copy(self) -> Self:
"""
Return a shallow copy of the object.
Returns:
`copy.copy(self)`
"""
return copy.copy(self)
def deepcopy(self) -> Self:
"""
Return a deep copy of the object.
Returns:
`copy.deepcopy(self)`
"""
return copy.deepcopy(self)