Skip to content

Commit

Permalink
scrapers: Fix a bunch of mypy type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
punchagan committed Sep 29, 2024
1 parent cc25e95 commit b022c9d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions app/scrapers/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def fetch_data(

@staticmethod
def parse_details(expense: Expense) -> Transaction:
details = expense.details.replace("M/s", "M.s")
details = str(expense.details).replace("M/s", "M.s")
axis_id = os.getenv("AXIS_CUSTOMID", "")
if details.startswith("UPIRECONP2PM/"):
_, transaction_id, _ = (each.strip() for each in details.split("/", 2))
Expand All @@ -291,8 +291,8 @@ def parse_details(expense: Expense) -> Transaction:
extra = details.split()[-1]
to_name_ctf = re.search("[A-Z]+", extra)
to_name_str = to_name_ctf.group() if to_name_ctf else ""
transaction_id = re.search("[0-9]+", extra)
transaction_id = transaction_id.group() if transaction_id else ""
transaction_id_ = re.search("[0-9]+", extra)
transaction_id = transaction_id_.group() if transaction_id_ else ""
transaction = Transaction(
transaction_type="UPI",
transaction_id=transaction_id,
Expand Down Expand Up @@ -496,7 +496,7 @@ def fetch_data(

@staticmethod
def parse_details(expense: Expense) -> Transaction:
details = expense.details
details = str(expense.details)
merchant = details.split(",", 1)[0]
ignore = bool(details.startswith("MB PAYMENT"))
return Transaction(
Expand Down
3 changes: 2 additions & 1 deletion app/scrapers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class Transaction:
class Source:
name = "base"
columns: dict[str, None | str | list[str]] = {}
date_format: str | None = None
date_format: str = ""
dtypes: dict[str, str] = {}

@staticmethod
def parse_details(expense: Expense) -> Transaction:
Expand Down
2 changes: 1 addition & 1 deletion app/scrapers/cash.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def fetch_data(

@staticmethod
def parse_details(expense: Expense) -> Transaction:
details = expense.details
details = str(expense.details)
remarks, category_name = (each.strip() for each in details.split("/"))
return Transaction(
transaction_type="Cash",
Expand Down

0 comments on commit b022c9d

Please sign in to comment.