mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-13 01:48:31 +02:00
typing cleanup
This commit is contained in:
parent
7c6e34deda
commit
62b733729e
4 changed files with 10 additions and 9 deletions
|
@ -12,8 +12,9 @@ from jrnl.messages import MsgText
|
|||
class BaseEncryption(ABC):
|
||||
_encoding: str
|
||||
_journal_name: str
|
||||
_config: dict
|
||||
|
||||
def __init__(self, journal_name, config):
|
||||
def __init__(self, journal_name: str, config: dict):
|
||||
self._encoding = "utf-8"
|
||||
self._journal_name = journal_name
|
||||
self._config = config
|
||||
|
|
|
@ -11,7 +11,7 @@ class BasePasswordEncryption(BaseEncryption):
|
|||
_max_attempts: int
|
||||
_password: str
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
self._attempts = 0
|
||||
self._max_attempts = 3
|
||||
|
@ -23,11 +23,11 @@ class BasePasswordEncryption(BaseEncryption):
|
|||
self.password = keyring_pw
|
||||
|
||||
@property
|
||||
def password(self):
|
||||
def password(self) -> str:
|
||||
return self._password
|
||||
|
||||
@password.setter
|
||||
def password(self, value):
|
||||
def password(self, value: str) -> None:
|
||||
self._password = value
|
||||
|
||||
def encrypt(self, text: str) -> str:
|
||||
|
@ -43,7 +43,7 @@ class BasePasswordEncryption(BaseEncryption):
|
|||
|
||||
return result
|
||||
|
||||
def _prompt_password(self):
|
||||
def _prompt_password(self) -> None:
|
||||
self._attempts, self.password = prompt_password(
|
||||
self._attempts, self._max_attempts
|
||||
)
|
||||
|
|
|
@ -38,7 +38,7 @@ def list_journals(configuration):
|
|||
return result
|
||||
|
||||
|
||||
def print_msg(msg: Message, **kwargs) -> Union[None, str]:
|
||||
def print_msg(msg: Message, **kwargs) -> None | str:
|
||||
"""Helper function to print a single message"""
|
||||
kwargs["style"] = msg.style
|
||||
return print_msgs([msg], **kwargs)
|
||||
|
@ -50,7 +50,7 @@ def print_msgs(
|
|||
style: MsgStyle = MsgStyle.NORMAL,
|
||||
get_input: bool = False,
|
||||
hide_input: bool = False,
|
||||
) -> Union[None, str]:
|
||||
) -> None | str:
|
||||
# Same as print_msg, but for a list
|
||||
text = Text("", end="")
|
||||
kwargs = style.decoration.args
|
||||
|
|
|
@ -43,7 +43,7 @@ def create_password(journal_name: str) -> str:
|
|||
return pw
|
||||
|
||||
|
||||
def prompt_password(attempts: int, max_attempts: int) -> tuple[int, str | None]:
|
||||
def prompt_password(attempts: int, max_attempts: int) -> tuple[int, str]:
|
||||
if attempts >= max_attempts:
|
||||
raise JrnlException(Message(MsgText.PasswordMaxTriesExceeded, MsgStyle.ERROR))
|
||||
|
||||
|
@ -55,7 +55,7 @@ def prompt_password(attempts: int, max_attempts: int) -> tuple[int, str | None]:
|
|||
Message(MsgText.Password, MsgStyle.PROMPT),
|
||||
get_input=True,
|
||||
hide_input=True,
|
||||
)
|
||||
) or ""
|
||||
|
||||
|
||||
def yesno(prompt: Message, default: bool = True) -> bool:
|
||||
|
|
Loading…
Add table
Reference in a new issue