From c5babf8badc0202ca3daf185c24597c12973c710 Mon Sep 17 00:00:00 2001 From: Richie Cahill Date: Sat, 28 Mar 2026 14:07:27 -0400 Subject: [PATCH] ran treefmt --- .../2026_03_25-attach_partitions_to_posts.py | 12 ++---------- python/alembic/env.py | 1 - python/data_science/ingest_congress.py | 9 ++------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/python/alembic/data_science_dev/versions/2026_03_25-attach_partitions_to_posts.py b/python/alembic/data_science_dev/versions/2026_03_25-attach_partitions_to_posts.py index a5b44da..5390566 100644 --- a/python/alembic/data_science_dev/versions/2026_03_25-attach_partitions_to_posts.py +++ b/python/alembic/data_science_dev/versions/2026_03_25-attach_partitions_to_posts.py @@ -46,12 +46,7 @@ ALREADY_ATTACHED_QUERY = text(""" def upgrade() -> None: """Attach all weekly partition tables to the posts parent table.""" connection = op.get_bind() - already_attached = { - row[0] - for row in connection.execute( - ALREADY_ATTACHED_QUERY, {"parent": f"{schema}.posts"} - ) - } + already_attached = {row[0] for row in connection.execute(ALREADY_ATTACHED_QUERY, {"parent": f"{schema}.posts"})} for year in range(PARTITION_START_YEAR, PARTITION_END_YEAR + 1): for week in range(1, iso_weeks_in_year(year) + 1): @@ -74,7 +69,4 @@ def downgrade() -> None: for year in range(PARTITION_START_YEAR, PARTITION_END_YEAR + 1): for week in range(1, iso_weeks_in_year(year) + 1): table_name = f"posts_{year}_{week:02d}" - op.execute( - f"ALTER TABLE {schema}.posts " - f"DETACH PARTITION {schema}.{table_name}" - ) + op.execute(f"ALTER TABLE {schema}.posts DETACH PARTITION {schema}.{table_name}") diff --git a/python/alembic/env.py b/python/alembic/env.py index 3055e22..b5532bd 100644 --- a/python/alembic/env.py +++ b/python/alembic/env.py @@ -3,7 +3,6 @@ from __future__ import annotations import logging -import re import sys from pathlib import Path from typing import TYPE_CHECKING, Any, Literal diff --git a/python/data_science/ingest_congress.py b/python/data_science/ingest_congress.py index 4635106..1182423 100644 --- a/python/data_science/ingest_congress.py +++ b/python/data_science/ingest_congress.py @@ -252,9 +252,7 @@ def ingest_votes(engine: Engine, congress_dirs: list[Path]) -> None: logger.info("Loaded %d bills into lookup map", len(bill_map)) existing_votes = { (row.congress, row.chamber, row.session, row.number) - for row in session.execute( - select(Vote.congress, Vote.chamber, Vote.session, Vote.number) - ).all() + for row in session.execute(select(Vote.congress, Vote.chamber, Vote.session, Vote.number)).all() } logger.info("Found %d existing votes in DB", len(existing_votes)) @@ -281,10 +279,7 @@ def ingest_votes(engine: Engine, congress_dirs: list[Path]) -> None: def _build_legislator_map(session: Session) -> dict[str, int]: """Build a mapping of bioguide_id -> legislator.id.""" - return { - row.bioguide_id: row.id - for row in session.execute(select(Legislator.bioguide_id, Legislator.id)).all() - } + return {row.bioguide_id: row.id for row in session.execute(select(Legislator.bioguide_id, Legislator.id)).all()} def _build_bill_map(session: Session) -> dict[tuple[int, str, int], int]: