From 7038d8546b19a291043fc0504b5e6711d045762e Mon Sep 17 00:00:00 2001 From: Mathias Date: Sat, 10 Oct 2026 17:46:16 +0100 Subject: [PATCH] mypy init --- alembic/env.py | 5 ++--- pyproject.toml | 7 +++++++ tests/test_transactions.py | 17 ++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/alembic/env.py b/alembic/env.py index 6dfa89b..de68b9d 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -65,9 +65,8 @@ def run_migrations_online() -> None: and associate a connection with the context. """ - if get_set_engine() is not None: - connectable = get_set_engine() - else: + connectable = get_set_engine() + if connectable is None: connectable = engine_from_config( config.get_section(config.config_ini_section, {}), prefix="sqlalchemy.", diff --git a/pyproject.toml b/pyproject.toml index 6a4c6fc..c5fb13c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,9 +29,16 @@ module-root = "" requires = ["uv_build>=0.12.9,<0.13.0"] build-backend = "uv_build" +[tool.mypy] +explicit_package_bases = true +mypy_path = "." + [tool.ruff] target-version = "py314" +[tool.black] +target-version = [ "py314" ] + [tool.ruff.lint] ignore = ["EXE"] diff --git a/tests/test_transactions.py b/tests/test_transactions.py index 6406891..e77b132 100644 --- a/tests/test_transactions.py +++ b/tests/test_transactions.py @@ -112,6 +112,7 @@ def test_consolidate_b4w_signed_amount_and_category(db_session: Session): CdtDbtInd="DBIT", ) staging = upsert_b4w(db_session, export, do_commit=False) + assert staging is not None consolidate_transactions( db_session, "b4w", B4wDb, map_b4w_to_transaction, do_commit=False ) @@ -130,10 +131,12 @@ def test_ingest_b4w_e2e_idempotent(db_session: Session): for _ in range(2): ingest_b4w(B4W_PATH, db_session) - staging_count = db_session.execute(select(func.count()).select_from(B4wDb)).scalar() + staging_count = db_session.execute( + select(func.count()).select_from(B4wDb) + ).scalar_one() transaction_count = db_session.execute( select(func.count()).select_from(TransactionDb) - ).scalar() + ).scalar_one() assert staging_count > 0 assert transaction_count == staging_count @@ -153,10 +156,10 @@ def test_ingest_comdirect_e2e_idempotent(db_session: Session): staging_count = db_session.execute( select(func.count()).select_from(ComdirectGiroDb) - ).scalar() + ).scalar_one() transaction_count = db_session.execute( select(func.count()).select_from(TransactionDb) - ).scalar() + ).scalar_one() assert staging_count > 0 assert transaction_count == staging_count @@ -174,13 +177,13 @@ def test_ingest_mixed_sources_into_one_table(db_session: Session): account_currency="EUR", ) - b4w_count = db_session.execute(select(func.count()).select_from(B4wDb)).scalar() + b4w_count = db_session.execute(select(func.count()).select_from(B4wDb)).scalar_one() giro_count = db_session.execute( select(func.count()).select_from(ComdirectGiroDb) - ).scalar() + ).scalar_one() transaction_count = db_session.execute( select(func.count()).select_from(TransactionDb) - ).scalar() + ).scalar_one() assert b4w_count > 0 assert giro_count > 0