Skip to content

Commit 30c2be2

Browse files
linting/code quality fixes
1 parent f6d5b57 commit 30c2be2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

konto/parser.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from csv import DictReader
44
from dataclasses import dataclass
55
from decimal import Decimal, InvalidOperation
6-
from typing import Any, Dict, List, Optional, Pattern
6+
from io import TextIOWrapper
7+
from typing import Any, Dict, List, Optional, Pattern, Tuple
78

89
from django.db.models import QuerySet
910

@@ -42,7 +43,7 @@ def __repr__(self):
4243
)
4344

4445

45-
def parse_camt_csv(csvfile):
46+
def parse_camt_csv(csvfile: TextIOWrapper) -> Tuple[List[Entry], List[str]]:
4647
results: List[Entry] = []
4748
errors: List[str] = []
4849

@@ -67,11 +68,11 @@ def parse_camt_csv(csvfile):
6768
for counter, row in enumerate(csvcontents):
6869
buchungstext: str = row["Buchungstext"]
6970
if buchungstext in ["GUTSCHR. UEBERWEISUNG", "ECHTZEIT-GUTSCHRIFT"]:
70-
entry: Optional[Entry] = pre_process_entry(counter, row, errors)
71+
entry: Optional[Entry] = _pre_process_entry(counter, row, errors)
7172
if entry:
72-
suche_rechnung(entry, offene_rechnungen, regex_cache)
73+
_suche_rechnung(entry, offene_rechnungen, regex_cache)
7374
if not entry.mapped_rechnung:
74-
suche_user(entry, users, regex_usernames, zuletzt_einlesen_date, errors)
75+
_suche_user(entry, users, regex_usernames, zuletzt_einlesen_date, errors)
7576
results.append(entry)
7677
elif buchungstext in [
7778
"ENTGELTABSCHLUSS",
@@ -94,7 +95,7 @@ def _generate_regex_cache(offene_rechnungen: QuerySet[Rechnung]) -> Dict[Rechnun
9495
return regex_cache
9596

9697

97-
def pre_process_entry(counter: int, row: Any, errors: List[str]) -> Optional[Entry]:
98+
def _pre_process_entry(counter: int, row: Any, errors: List[str]) -> Optional[Entry]:
9899
try:
99100
datum = datetime.datetime.strptime(row["Buchungstag"], "%d.%m.%y").date()
100101
except ValueError:
@@ -126,7 +127,7 @@ def pre_process_entry(counter: int, row: Any, errors: List[str]) -> Optional[Ent
126127
)
127128

128129

129-
def suche_rechnung(
130+
def _suche_rechnung(
130131
entry: Entry,
131132
offene_rechnungen: QuerySet[Rechnung],
132133
regex_cache: Dict[Rechnung, Pattern[str]],
@@ -154,7 +155,7 @@ def suche_rechnung(
154155
entry.erwarteter_betrag = rechnung.gesamtsumme
155156

156157

157-
def suche_user(
158+
def _suche_user(
158159
entry: Entry,
159160
users: QuerySet[Schulden],
160161
regex_usernames: Dict[Schulden, Pattern[str]],

0 commit comments

Comments
 (0)