use Self type
This commit is contained in:
parent
1463535676
commit
4482ede3a7
17 changed files with 142 additions and 205 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from typing import TypeVar
|
||||
from typing import Self
|
||||
import copy
|
||||
|
||||
import numpy
|
||||
|
|
@ -10,9 +10,6 @@ from .traits import PositionableImpl, LayerableImpl, Copyable, Pivotable, Repeat
|
|||
from .traits import AnnotatableImpl
|
||||
|
||||
|
||||
L = TypeVar('L', bound='Label')
|
||||
|
||||
|
||||
class Label(PositionableImpl, LayerableImpl, RepeatableImpl, AnnotatableImpl,
|
||||
Pivotable, Copyable, metaclass=AutoSlots):
|
||||
"""
|
||||
|
|
@ -53,7 +50,7 @@ class Label(PositionableImpl, LayerableImpl, RepeatableImpl, AnnotatableImpl,
|
|||
self.repetition = repetition
|
||||
self.annotations = annotations if annotations is not None else {}
|
||||
|
||||
def __copy__(self: L) -> L:
|
||||
def __copy__(self) -> Self:
|
||||
return type(self)(
|
||||
string=self.string,
|
||||
offset=self.offset.copy(),
|
||||
|
|
@ -61,13 +58,13 @@ class Label(PositionableImpl, LayerableImpl, RepeatableImpl, AnnotatableImpl,
|
|||
repetition=self.repetition,
|
||||
)
|
||||
|
||||
def __deepcopy__(self: L, memo: dict | None = None) -> L:
|
||||
def __deepcopy__(self, memo: dict | None = None) -> Self:
|
||||
memo = {} if memo is None else memo
|
||||
new = copy.copy(self)
|
||||
new._offset = self._offset.copy()
|
||||
return new
|
||||
|
||||
def rotate_around(self: L, pivot: ArrayLike, rotation: float) -> L:
|
||||
def rotate_around(self, pivot: ArrayLike, rotation: float) -> Self:
|
||||
"""
|
||||
Rotate the label around a point.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue