Skip to content

Commit

Permalink
dashboard: Fix more issues caught by type hints
Browse files Browse the repository at this point in the history
Improving the return type of the function get_sqlalchemy_session brought
up some typing issues.
  • Loading branch information
punchagan committed Sep 30, 2024
1 parent 3571399 commit 941bb2c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/pages/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ def load_data(
def get_categories() -> dict[int, Category]:
session = get_sqlalchemy_session()
categories = session.query(Category).order_by("id").all()
return {cat.id: cat for cat in categories}
return {cast(int, cat.id): cat for cat in categories}


@st.cache_data
def get_tags() -> dict[int, Tag]:
session = get_sqlalchemy_session()
tags = session.query(Tag).order_by("id").all()
return {tag.id: tag for tag in tags}
return {cast(int, tag.id): tag for tag in tags}


@st.cache_data
Expand Down Expand Up @@ -180,6 +180,8 @@ def write_changes_to_db(df: pd.DataFrame) -> None:
# Fetch the expense from the DB
session = get_sqlalchemy_session()
expense = session.get(Expense, {"id": row["id"]})
if expense is None:
continue

for key, value in change.items():
if key == "counterparty_name" and value.endswith("**"):
Expand Down

0 comments on commit 941bb2c

Please sign in to comment.