Skip to content

Commit

Permalink
fixing code under python 3.9
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Ramsay <[email protected]>
  • Loading branch information
seapagan committed Sep 22, 2023
1 parent 9c5e548 commit fb29d08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,4 @@ cython_debug/
openapi.json
test.db
docs/CNAME
.python-version
13 changes: 10 additions & 3 deletions app/database/helpers.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
"""Define some database helper functions."""
from __future__ import annotations

from typing import TYPE_CHECKING, Union

from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession

from app.models.user import User

if TYPE_CHECKING:
from sqlalchemy.ext.asyncio import AsyncSession


async def get_all_users_(session: AsyncSession):
"""Return all Users in the database."""
result = await session.execute(select(User))
return result.scalars().all()


async def get_user_by_email_(email, session: AsyncSession) -> User | None:
async def get_user_by_email_(email, session: AsyncSession) -> Union[User, None]:
"""Return a specific user by their email address."""
result = await session.execute(select(User).where(User.email == email))
return result.scalars().first()


async def get_user_by_id_(user_id: int, session: AsyncSession) -> User | None:
async def get_user_by_id_(
user_id: int, session: AsyncSession
) -> Union[User, None]:
"""Return a specific user by their email address."""
result = await session.execute(select(User).where(User.id == user_id))
return result.scalars().first()
Expand Down

0 comments on commit fb29d08

Please sign in to comment.