fix linting issues in current codebase

This commit is contained in:
Jonathan Wren 2022-10-30 14:30:18 -07:00
parent b894eab6ac
commit af8d7536d9
No known key found for this signature in database
4 changed files with 11 additions and 15 deletions

View file

@ -2,6 +2,7 @@
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import base64 import base64
import contextlib
import hashlib import hashlib
import logging import logging
import os import os
@ -202,10 +203,9 @@ def set_keychain(journal_name, password):
import keyring import keyring
if password is None: if password is None:
try: cm = contextlib.suppress(keyring.errors.KeyringError)
with cm:
keyring.delete_password("jrnl", journal_name) keyring.delete_password("jrnl", journal_name)
except keyring.errors.KeyringError:
pass
else: else:
try: try:
keyring.set_password("jrnl", journal_name, password) keyring.set_password("jrnl", journal_name, password)

View file

@ -1,10 +1,6 @@
# 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.Message import Message from jrnl.messages.Message import Message # noqa: F401
from jrnl.messages.MsgStyle import MsgStyle from jrnl.messages.MsgStyle import MsgStyle # noqa: F401
from jrnl.messages.MsgText import MsgText from jrnl.messages.MsgText import MsgText # noqa: F401
Message = Message
MsgStyle = MsgStyle
MsgText = MsgText

View file

@ -2,7 +2,7 @@
# License: https://www.gnu.org/licenses/gpl-3.0.html # License: https://www.gnu.org/licenses/gpl-3.0.html
import textwrap import textwrap
from typing import Union from typing import Optional
from rich.console import Console from rich.console import Console
from rich.text import Text from rich.text import Text
@ -69,7 +69,7 @@ def list_journals(configuration, format=None):
return journal_list_to_stdout(journal_list) return journal_list_to_stdout(journal_list)
def print_msg(msg: Message, **kwargs) -> Union[None, str]: def print_msg(msg: Message, **kwargs) -> Optional[str]:
"""Helper function to print a single message""" """Helper function to print a single message"""
kwargs["style"] = msg.style kwargs["style"] = msg.style
return print_msgs([msg], **kwargs) return print_msgs([msg], **kwargs)
@ -81,7 +81,7 @@ def print_msgs(
style: MsgStyle = MsgStyle.NORMAL, style: MsgStyle = MsgStyle.NORMAL,
get_input: bool = False, get_input: bool = False,
hide_input: bool = False, hide_input: bool = False,
) -> Union[None, str]: ) -> Optional[str]:
# Same as print_msg, but for a list # Same as print_msg, but for a list
text = Text("", end="") text = Text("", end="")
kwargs = style.decoration.args kwargs = style.decoration.args

View file

@ -78,11 +78,11 @@ class MarkdownExporter(TextExporter):
out = [] out = []
year, month = -1, -1 year, month = -1, -1
for e in journal.entries: for e in journal.entries:
if not e.date.year == year: if e.date.year != year:
year = e.date.year year = e.date.year
out.append("# " + str(year)) out.append("# " + str(year))
out.append("") out.append("")
if not e.date.month == month: if e.date.month != month:
month = e.date.month month = e.date.month
out.append("## " + e.date.strftime("%B")) out.append("## " + e.date.strftime("%B"))
out.append("") out.append("")