Skip to content

Commit

Permalink
ci: remove pull-request template
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBernstorff committed Oct 27, 2023
1 parent 9da7e6c commit bfbe55d
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 39 deletions.
8 changes: 0 additions & 8 deletions .github/pull_request_template.md

This file was deleted.

4 changes: 2 additions & 2 deletions application/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


# helper for creating anki connect requests
def request(action: Any, **params: Any) -> Dict[str, Any]:
def request(action: Any, **params: Any) -> dict[str, Any]:
return {"action": action, "params": params, "version": 6}


Expand Down Expand Up @@ -83,6 +83,6 @@ def main(
sleep(sleep_seconds)
main(input_dir=input_dir, watch=watch, host_output_dir=host_output_dir)


if __name__ == "__main__":
typer.run(main)
4 changes: 2 additions & 2 deletions src/personal_mnemonic_medium/card_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def __init__(
def run(
self,
input_path: Path,
) -> List[AnkiCard]:
notes: List[Document] = []
) -> list[AnkiCard]:
notes: list[Document] = []
if input_path.is_dir():
notes += list(self.document_factory.get_notes_from_dir(dir_path=input_path))

Expand Down
11 changes: 6 additions & 5 deletions src/personal_mnemonic_medium/exporters/anki/card_types/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import os
import re
from abc import ABC, abstractmethod
from collections.abc import Callable
from pathlib import Path
from typing import Any, Callable, List, Optional, Tuple
from typing import Any, List, Optional, Tuple

import genanki
from personal_mnemonic_medium.exporters.anki.globals import CONFIG
Expand All @@ -22,7 +23,7 @@ class AnkiCard(ABC):

def __init__(
self,
fields: List[str],
fields: list[str],
source_prompt: Prompt,
url_generator: Callable[[Path, Optional[int]], str] = get_obsidian_url,
html_compiler: Callable[[str], str] = compile_field,
Expand All @@ -38,11 +39,11 @@ def source_markdown(self) -> str:
return self.source_doc.content

@property
def html_fields(self) -> List[str]:
def html_fields(self) -> list[str]:
return list(map(self.html_compiler, self.markdown_fields))

@property
def tags(self) -> List[str]:
def tags(self) -> list[str]:
return self.source_doc.tags

@property
Expand Down Expand Up @@ -132,7 +133,7 @@ def to_genanki_note(self) -> genanki.Note:
tags=self.tags,
)

def make_ref_pair(self, filename: str) -> Tuple[Path, str]:
def make_ref_pair(self, filename: str) -> tuple[Path, str]:
"""Take a filename relative to the card, and make it absolute."""
newname = "%".join(filename.split(os.sep))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
from collections.abc import Callable
from pathlib import Path
from typing import Callable, List, Optional
from typing import List, Optional

import genanki
from personal_mnemonic_medium.exporters.anki.card_types.base import AnkiCard
Expand All @@ -18,7 +19,7 @@
class AnkiCloze(AnkiCard):
def __init__(
self,
fields: List[str],
fields: list[str],
source_prompt: Prompt,
url_generator: Callable[[Path, Optional[int]], str] = get_obsidian_url,
html_compiler: Callable[[str], str] = compile_field,
Expand Down
5 changes: 3 additions & 2 deletions src/personal_mnemonic_medium/exporters/anki/card_types/qa.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Callable
from pathlib import Path
from typing import Callable, List, Optional
from typing import List, Optional

import genanki
from personal_mnemonic_medium.exporters.anki.card_types.base import AnkiCard
Expand All @@ -17,7 +18,7 @@
class AnkiQA(AnkiCard):
def __init__(
self,
fields: List[str],
fields: list[str],
source_prompt: Prompt,
url_generator: Callable[[Path, Optional[int]], str] = get_obsidian_url,
html_compiler: Callable[[str], str] = compile_field,
Expand Down
2 changes: 1 addition & 1 deletion src/personal_mnemonic_medium/exporters/anki/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"card_model_template_cloze": CLOZE_MODEL_TEMPLATE,
}

VERSION_LOG: Dict[Any, Any] = {}
VERSION_LOG: dict[Any, Any] = {}
Q_TYPE_TAG = {
"G": "med/type/1_GP",
"A": "med/type/2_Acute_care",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __getitem__(self, deckname: str) -> Any:
@dataclass(frozen=True)
class DeckBundle:
deck: genanki.Deck
media: Set[str]
media: set[str]

def get_package(self) -> genanki.Package:
return genanki.Package(deck_or_decks=self.deck, media_files=list(self.media))
Expand All @@ -61,7 +61,7 @@ def __init__(self) -> None:
pass

@staticmethod
def cards_to_deck_bundle(cards: List[AnkiCard]) -> DeckBundle:
def cards_to_deck_bundle(cards: list[AnkiCard]) -> DeckBundle:
"""Take an iterable prompts, output an .apkg in a file called output_name.
NOTE: We _must_ be in a temp directory.
"""
Expand All @@ -75,7 +75,7 @@ def cards_to_deck_bundle(cards: List[AnkiCard]) -> DeckBundle:
@staticmethod
def cards_to_deck(
cards: Sequence[AnkiCard],
) -> tuple[genanki.Deck, Set[str]]:
) -> tuple[genanki.Deck, set[str]]:
media = set()

deck_name = cards[0].deckname
Expand Down Expand Up @@ -103,7 +103,7 @@ def cards_to_deck(
def prompts_to_cards(
self,
prompts: Sequence[Prompt],
) -> List[AnkiCard]:
) -> list[AnkiCard]:
"""Takes an iterable of prompts and turns them into AnkiCards"""

cards: list[AnkiCard] = []
Expand Down
8 changes: 4 additions & 4 deletions src/personal_mnemonic_medium/exporters/anki/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


# helper for creating anki connect requests
def request(action: Any, **params: Any) -> Dict[str, Any]:
def request(action: Any, **params: Any) -> dict[str, Any]:
return {"action": action, "params": params, "version": 6}


Expand Down Expand Up @@ -139,19 +139,19 @@ def sync_deck(


def get_md_note_infos(deck_bundle: DeckBundle) -> set[str]:
md_notes: List[Note] = deck_bundle.deck.notes
md_notes: list[Note] = deck_bundle.deck.notes
md_note_guids = {str(n.guid) for n in md_notes}
return md_note_guids


def get_anki_note_infos(deck_bundle: DeckBundle) -> tuple[dict[str, Any], set[str]]:
anki_card_ids: List[int] = invoke(
anki_card_ids: list[int] = invoke(
"findCards",
query=f'"deck:{deck_bundle.deck.name}"',
)

# get a list of anki notes in the deck
anki_note_ids: List[int] = invoke("cardsToNotes", cards=anki_card_ids)
anki_note_ids: list[int] = invoke("cardsToNotes", cards=anki_card_ids)

# get the note info for the notes in the deck
anki_notes_info = invoke("notesInfo", notes=anki_note_ids)
Expand Down
2 changes: 1 addition & 1 deletion src/personal_mnemonic_medium/note_factories/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _replace_alias_wiki_links(text: str) -> str:

return text

def get_tags(self, input_str: str, import_time: str) -> List[str]:
def get_tags(self, input_str: str, import_time: str) -> list[str]:
file_tags = [import_time]

if self.has_supplementary_tags(input_str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self) -> None:
pass

@staticmethod
def _break_string_by_two_or_more_newlines(string: str) -> List[str]:
def _break_string_by_two_or_more_newlines(string: str) -> list[str]:
"""Break string into a list by 2+ newlines in a row."""
return re.split(r"(\n\n)+", string)

Expand Down
2 changes: 1 addition & 1 deletion src/personal_mnemonic_medium/prompt_extractors/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(
self,
note_uuid: str,
source_note: Document,
tags: Optional[List[str]] = None,
tags: Optional[list[str]] = None,
line_nr: Optional[int] = None,
):
self.tags = tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _get_first_answer(self, string: str) -> str:
return answer[len(self.answer_prefix) + 2 :].rstrip()

@staticmethod
def _break_string_by_two_or_more_newlines(string: str) -> List[str]:
def _break_string_by_two_or_more_newlines(string: str) -> list[str]:
"""Break string into a list by 2+ newlines in a row."""
return re.split(r"(\n\n)+", string)

Expand Down
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def update(c: Context):
@task(iterable="pytest_args")
def test(
c: Context,
python_versions: List[str] = (SUPPORTED_PYTHON_VERSIONS[0],), # type: ignore
python_versions: list[str] = (SUPPORTED_PYTHON_VERSIONS[0],), # type: ignore
pytest_args: List[str] = [], # noqa
):
"""Run tests"""
Expand Down Expand Up @@ -382,7 +382,7 @@ def test(

def test_for_rej():
# Get all paths in current directory or subdirectories that end in .rej
rej_files = list(Path(".").rglob("*.rej"))
rej_files = list(Path().rglob("*.rej"))

if len(rej_files) > 0:
print(f"\n{msg_type.FAIL} Found .rej files leftover from cruft update.\n")
Expand Down
6 changes: 3 additions & 3 deletions tests/exporters/anki/test_card_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def __init__(
self,
document_factory: DocumentFactory = MarkdownNoteFactory(), # noqa: B008
prompt_extractors: Sequence[PromptExtractor] = [
QAPromptExtractor(), # noqa: B008
ClozePromptExtractor(), # noqa: B008
QAPromptExtractor(),
ClozePromptExtractor(),
],
card_exporter: CardExporter = AnkiPackageGenerator(), # noqa: B008
) -> None:
Expand All @@ -42,7 +42,7 @@ def __init__(
def test_card_pipeline(
self,
input_path: Path,
) -> List[AnkiCard]:
) -> list[AnkiCard]:
return self.run(
input_path=input_path,
)
Expand Down

0 comments on commit bfbe55d

Please sign in to comment.