use Self type

This commit is contained in:
Jan Petykiewicz 2023-02-23 13:37:34 -08:00 committed by jan
commit 4482ede3a7
17 changed files with 142 additions and 205 deletions

View file

@ -1,4 +1,4 @@
from typing import TypeVar, TYPE_CHECKING
from typing import Self, TYPE_CHECKING
from abc import ABCMeta, abstractmethod
from ..error import MasqueError
@ -11,10 +11,6 @@ if TYPE_CHECKING:
from ..repetition import Repetition
T = TypeVar('T', bound='Repeatable')
I = TypeVar('I', bound='RepeatableImpl')
class Repeatable(metaclass=ABCMeta):
"""
Abstract class for all repeatable entities
@ -41,7 +37,7 @@ class Repeatable(metaclass=ABCMeta):
---- Methods
'''
@abstractmethod
def set_repetition(self: T, repetition: 'Repetition' | None) -> T:
def set_repetition(self, repetition: 'Repetition' | None) -> Self:
"""
Set the repetition
@ -80,6 +76,6 @@ class RepeatableImpl(Repeatable, metaclass=ABCMeta):
'''
---- Non-abstract methods
'''
def set_repetition(self: I, repetition: 'Repetition' | None) -> I:
def set_repetition(self, repetition: 'Repetition' | None) -> Self:
self.repetition = repetition
return self