Skip to content

Commit c99da80

Browse files
committed
chore: reformat and fix lints
1 parent fbeb79c commit c99da80

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

src/apyanki/anki.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,13 @@ def list_tags(self, sort_by_count: bool = False) -> None:
333333
table.add_column("notes", style="magenta", justify="right")
334334

335335
if sort_by_count:
336-
sorter = lambda x: x[1]
336+
337+
def sorter(x): # type: ignore[no-untyped-def]
338+
return x[1]
337339
else:
338-
sorter = lambda x: x[0]
340+
341+
def sorter(x): # type: ignore[no-untyped-def]
342+
return x[0]
339343

340344
tags = [(t, len(self.col.find_notes(f"tag:{t}"))) for t in self.col.tags.all()]
341345
for tag, n in sorted(tags, key=sorter):
@@ -482,7 +486,7 @@ def add_notes_with_editor(
482486
model = self.set_model(model_name)
483487
input_strings += [
484488
x
485-
for y in [[f'## {field["name"]}', ""] for field in model["flds"]]
489+
for y in [[f"## {field['name']}", ""] for field in model["flds"]]
486490
for x in y
487491
]
488492

src/apyanki/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def edit(query: str, force_multiple: bool) -> None:
530530
preview_text = note.n.fields[0][:50].replace("\n", " ")
531531
if len(preview_text) == 50:
532532
preview_text += "..."
533-
console.print(f"{i+1}. nid:{note.n.id} - {preview_text}")
533+
console.print(f"{i + 1}. nid:{note.n.id} - {preview_text}")
534534

535535
console.print(
536536
"\nHints:\n"
@@ -544,7 +544,7 @@ def edit(query: str, force_multiple: bool) -> None:
544544
for i, note in enumerate(notes):
545545
if len(notes) > 1:
546546
console.print(
547-
f"\nEditing note {i+1} of {len(notes)} (nid: {note.n.id})"
547+
f"\nEditing note {i + 1} of {len(notes)} (nid: {note.n.id})"
548548
)
549549

550550
# Show a brief preview of the note
@@ -640,7 +640,7 @@ def tag(
640640
if changes.count > 0:
641641
console.print(f"[yellow]Purged {changes.count} unused tags.")
642642
else:
643-
console.print(f"No unused tags found.")
643+
console.print("No unused tags found.")
644644

645645
return
646646

src/apyanki/note.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
from rich.table import Table
1818
from rich.text import Text
1919

20-
if TYPE_CHECKING:
21-
from anki.notes import NoteId
22-
from anki.cards import CardId
2320

2421
from apyanki import cards
2522
from apyanki.config import cfg
@@ -272,7 +269,7 @@ def change_model(self) -> Optional[Note]:
272269
console.clear()
273270
console.print("Please choose new model:")
274271
for n, m in enumerate(models):
275-
console.print(f" {n+1}: {m}")
272+
console.print(f" {n + 1}: {m}")
276273
index: int = console.prompt_int(">>> ", suffix="") - 1
277274
try:
278275
new_model = models[index]
@@ -452,9 +449,9 @@ def review(
452449
note_number_string = ""
453450
if i is not None:
454451
if number_of_notes:
455-
note_number_string = f" {i+1} of {number_of_notes}"
452+
note_number_string = f" {i + 1} of {number_of_notes}"
456453
else:
457-
note_number_string = f" {i+1}"
454+
note_number_string = f" {i + 1}"
458455

459456
menu = Columns(
460457
[
@@ -590,7 +587,7 @@ def add_to_collection(self, anki: Anki) -> Note:
590587
field_names = [x.replace(" (markdown)", "") for x in self.fields.keys()]
591588
for x, y in zip(model_field_names, field_names):
592589
if x != y:
593-
console.print("Warning: Inconsistent field names " f"({x} != {y})")
590+
console.print(f"Warning: Inconsistent field names ({x} != {y})")
594591

595592
notetype = anki.col.models.current(for_deck=False)
596593
new_note = anki.col.new_note(notetype)

src/apyanki/utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def choose(items: list[chooseType], text: str = "Choose from list:") -> chooseTy
6161
"""Choose from list of items"""
6262
console.print(text)
6363
for i, element in enumerate(items):
64-
console.print(f"{i+1}: {element}")
64+
console.print(f"{i + 1}: {element}")
6565

6666
index = _read_number_between(1, len(items)) - 1
6767
return items[index]

tests/test_batch_edit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test batch editing"""
2+
# ruff: noqa: F401, F811
23

34
import os
45
import pytest
@@ -33,11 +34,11 @@ def test_add_from_file(collection):
3334
"""
3435
model: Basic
3536
tags: marked
36-
37+
3738
# Note 1
3839
## Front
3940
Question?
40-
41+
4142
## Back
4243
Answer.
4344
"""

0 commit comments

Comments
 (0)