masque/masque/traits/copyable.py

31 lines
542 B
Python
Raw Permalink Normal View History

2023-02-23 13:37:34 -08:00
from typing import Self
import copy
2024-07-28 20:18:12 -07:00
class Copyable:
"""
2023-04-07 23:19:55 -07:00
Trait class which adds .copy() and .deepcopy()
"""
__slots__ = ()
2023-04-07 23:19:55 -07:00
#
# 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)