masque/masque/traits/copyable.py

32 lines
595 B
Python
Raw Normal View History

2023-02-23 13:37:34 -08:00
from typing import Self
from abc import ABCMeta
import copy
class Copyable(metaclass=ABCMeta):
"""
Abstract class which adds .copy() and .deepcopy()
"""
__slots__ = ()
'''
---- Non-abstract methods
'''
2023-02-23 13:37:34 -08:00
def copy(self) -> Self:
"""
Return a shallow copy of the object.
Returns:
`copy.copy(self)`
"""
return copy.copy(self)
2023-02-23 13:37:34 -08:00
def deepcopy(self) -> Self:
"""
Return a deep copy of the object.
Returns:
`copy.deepcopy(self)`
"""
return copy.deepcopy(self)