mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-30 22:46:12 +02:00
Add type hints (#1614)
* Add type hints * Fix linters * Add remaining type hints * Fix type-checking linter * Update jrnl/DayOneJournal.py Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
This commit is contained in:
parent
c1eb0c54a3
commit
30b41fdb88
28 changed files with 219 additions and 120 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
import os
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from jrnl.exception import JrnlException
|
||||
from jrnl.messages import Message
|
||||
|
@ -11,6 +12,10 @@ from jrnl.messages import MsgText
|
|||
from jrnl.output import print_msg
|
||||
from jrnl.plugins.text_exporter import TextExporter
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from jrnl.Entry import Entry
|
||||
from jrnl.Journal import Journal
|
||||
|
||||
|
||||
class YAMLExporter(TextExporter):
|
||||
"""This Exporter can convert entries and journals into Markdown formatted text with YAML front matter."""
|
||||
|
@ -19,7 +24,7 @@ class YAMLExporter(TextExporter):
|
|||
extension = "md"
|
||||
|
||||
@classmethod
|
||||
def export_entry(cls, entry, to_multifile=True):
|
||||
def export_entry(cls, entry: "Entry", to_multifile: bool = True) -> str:
|
||||
"""Returns a markdown representation of a single entry, with YAML front matter."""
|
||||
if to_multifile is False:
|
||||
raise JrnlException(Message(MsgText.YamlMustBeDirectory, MsgStyle.ERROR))
|
||||
|
@ -124,6 +129,6 @@ class YAMLExporter(TextExporter):
|
|||
)
|
||||
|
||||
@classmethod
|
||||
def export_journal(cls, journal):
|
||||
def export_journal(cls, journal: "Journal"):
|
||||
"""Returns an error, as YAML export requires a directory as a target."""
|
||||
raise JrnlException(Message(MsgText.YamlMustBeDirectory, MsgStyle.ERROR))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue