Skip to content

Commit d3a02e8

Browse files
committed
chore: code clean up
1 parent 8b92b42 commit d3a02e8

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/elections/crud.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
from collections.abc import Sequence
2+
13
import sqlalchemy
24
from sqlalchemy.ext.asyncio import AsyncSession
35

46
from elections.tables import Election, NomineeApplication, NomineeInfo
57
from officers.types import OfficerPositionEnum
68

79

8-
async def get_all_elections(db_session: AsyncSession) -> list[Election]:
9-
# TODO: can this return None?
10+
async def get_all_elections(db_session: AsyncSession) -> Sequence[Election]:
1011
election_list = (await db_session.scalars(
1112
sqlalchemy
1213
.select(Election)
@@ -55,7 +56,7 @@ async def get_all_registrations_of_user(
5556
db_session: AsyncSession,
5657
computing_id: str,
5758
election_slug: str
58-
) -> list[NomineeApplication] | None:
59+
) -> Sequence[NomineeApplication] | None:
5960
registrations = (await db_session.scalars(
6061
sqlalchemy
6162
.select(NomineeApplication)
@@ -86,7 +87,7 @@ async def get_one_registration_in_election(
8687
async def get_all_registrations_in_election(
8788
db_session: AsyncSession,
8889
election_slug: str,
89-
) -> list[NomineeApplication] | None:
90+
) -> Sequence[NomineeApplication] | None:
9091
registrations = (await db_session.scalars(
9192
sqlalchemy
9293
.select(NomineeApplication)

src/elections/tables.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import date, datetime
1+
from datetime import datetime
22

33
from sqlalchemy import (
44
DateTime,
@@ -7,10 +7,8 @@
77
String,
88
Text,
99
)
10-
from sqlalchemy.ext.hybrid import hybrid_method, hybrid_property
10+
from sqlalchemy.ext.hybrid import hybrid_property
1111
from sqlalchemy.orm import Mapped, mapped_column
12-
from sqlalchemy.orm.attributes import set_attribute
13-
from sqlalchemy.util import hybridproperty
1412

1513
from constants import (
1614
COMPUTING_ID_LEN,

tests/integration/test_elections.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import asyncio
2-
import json
32
from datetime import datetime, timedelta
43

54
import pytest
65
from httpx import ASGITransport, AsyncClient
76

87
from src import load_test_db
9-
from src.auth.crud import create_user_session, get_computing_id, update_site_user
8+
from src.auth.crud import create_user_session
109
from src.database import SQLALCHEMY_TEST_DATABASE_URL, DatabaseSessionManager
1110
from src.elections.crud import (
1211
# election crud

0 commit comments

Comments
 (0)