Skip to content

Commit

Permalink
default token
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Jul 15, 2024
1 parent 0e50582 commit bf275fe
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cantok/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ class CounterCancellationError(CancellationError):

class TimeoutCancellationError(CancellationError):
pass

class impossibleException(CancellationError):
pass
33 changes: 33 additions & 0 deletions cantok/tokens/default_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from cantok import AbstractToken
from cantok.errors import impossibleException


class DefaultToken(AbstractToken):
exception = impossibleException

def __init__(self):
super().__init__()

def superpower(self) -> bool:
return False

def text_representation_of_superpower(self) -> str:
return ''

def get_superpower_exception_message(self) -> str:
return 'This exception should not be raised.' # pragma: no cover

@property
def cancelled(self) -> bool:
return False

@cancelled.setter
def cancelled(self, new_value: bool) -> None:
if new_value == True:
raise ValueError('You cannot cancel a default token.')

def keep_on(self) -> bool:
return True

def is_cancelled(self, direct: bool = True) -> bool:
return False

0 comments on commit bf275fe

Please sign in to comment.