From 941bb2c524c0ac2a0c8502a13ea2d27f441a5061 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Mon, 30 Sep 2024 09:30:51 +0530 Subject: [PATCH] dashboard: Fix more issues caught by type hints Improving the return type of the function get_sqlalchemy_session brought up some typing issues. --- app/pages/dashboard.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/pages/dashboard.py b/app/pages/dashboard.py index e1b0760..a431f4e 100644 --- a/app/pages/dashboard.py +++ b/app/pages/dashboard.py @@ -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 @@ -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("**"):