fix: skip command in interactive

Also replace old DB `get` method with `select` and fix issues caught by
mypy.
This commit is contained in:
Luís Murta 2026-01-01 16:18:17 +00:00
parent 7b4815dee5
commit 1aae7d8748
Signed by: satprog
GPG Key ID: 169EF1BBD7049F94

View File

@ -36,23 +36,23 @@ class Interactive:
uncategorized = session.select( uncategorized = session.select(
Transaction, lambda: ~Transaction.category.has() Transaction, lambda: ~Transaction.category.has()
) )
uncategorized.sort() list(uncategorized).sort()
n = len(uncategorized) n = len(uncategorized)
print(f"{n} left to categorize") print(f"{n} left to categorize")
i = 0 i = 0
new = [] new = []
while (command := input("$ ")) != "quit" and i < len(uncategorized): while i < len(uncategorized):
current = uncategorized[i] if len(new) == 0 else new.pop() current = uncategorized[i] if len(new) == 0 else new.pop()
print(current) print(current)
command = input("$ ")
match command: match command:
case "help": case "help":
print(self.help) print(self.help)
case "skip": case "skip":
if len(uncategorized) == 0:
i += 1 i += 1
case "quit": case "quit":
@ -89,7 +89,7 @@ class Interactive:
for tag in tags: for tag in tags:
if tag not in [t.name for t in self.tags]: if tag not in [t.name for t in self.tags]:
session.insert([Tag(tag)]) session.insert([Tag(tag)])
self.tags = session.get(Tag) self.tags = session.select(Tag)
current.tags.add(TransactionTag(tag)) current.tags.add(TransactionTag(tag))
@ -98,7 +98,7 @@ class Interactive:
def split(self, original: Transaction) -> list[SplitTransaction]: def split(self, original: Transaction) -> list[SplitTransaction]:
total = original.amount total = original.amount
new = [] new: list[SplitTransaction] = []
done = False done = False
while not done: while not done:
@ -114,7 +114,7 @@ class Interactive:
amount = decimal.Decimal(input("amount: ")) amount = decimal.Decimal(input("amount: "))
new.append( new.append(
SplitTransaction( SplitTransaction(
original.date, original.description, amount, original.id original.date, original.description, amount, original=original.id
) )
) )