fix type-checking issues in current codebase

This commit is contained in:
Jonathan Wren 2022-10-30 12:33:58 -07:00
parent 37989ced0a
commit eccb8b7d9f
No known key found for this signature in database
3 changed files with 15 additions and 8 deletions

View file

@ -1,14 +1,18 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2022 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from jrnl.messages import Message from typing import TYPE_CHECKING
from jrnl.output import print_msg from jrnl.output import print_msg
if TYPE_CHECKING:
from jrnl.messages import Message
class JrnlException(Exception): class JrnlException(Exception):
"""Common exceptions raised by jrnl.""" """Common exceptions raised by jrnl."""
def __init__(self, *messages: Message): def __init__(self, *messages: "Message"):
self.messages = messages self.messages = messages
def print(self) -> None: def print(self) -> None:

View file

@ -1,14 +1,16 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2022 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from typing import TYPE_CHECKING
from typing import Mapping from typing import Mapping
from typing import NamedTuple from typing import NamedTuple
from jrnl.messages.MsgStyle import MsgStyle from jrnl.messages.MsgStyle import MsgStyle
from jrnl.messages.MsgText import MsgText
if TYPE_CHECKING:
from jrnl.messages.MsgText import MsgText
class Message(NamedTuple): class Message(NamedTuple):
text: MsgText text: "MsgText"
style: MsgStyle = MsgStyle.NORMAL style: MsgStyle = MsgStyle.NORMAL
params: Mapping = {} params: Mapping = {}

View file

@ -1,14 +1,15 @@
# Copyright © 2012-2022 jrnl contributors # Copyright © 2012-2022 jrnl contributors
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
from typing import TYPE_CHECKING
from argparse import Namespace
from jrnl.config import make_yaml_valid_dict from jrnl.config import make_yaml_valid_dict
from jrnl.config import update_config from jrnl.config import update_config
if TYPE_CHECKING:
from argparse import Namespace
# import logging # import logging
def apply_overrides(args: Namespace, base_config: dict) -> dict: def apply_overrides(args: "Namespace", base_config: dict) -> dict:
"""Unpack CLI provided overrides into the configuration tree. """Unpack CLI provided overrides into the configuration tree.
:param overrides: List of configuration key-value pairs collected from the CLI :param overrides: List of configuration key-value pairs collected from the CLI