Skip to content

Commit 7ee99b1

Browse files
committed
cleanup
1 parent b79fcdf commit 7ee99b1

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/postgres-database/src/simcore_postgres_database/utils_products.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
""" Common functions to access products table
2-
3-
"""
1+
"""Common functions to access products table"""
42

53
import warnings
64

75
import sqlalchemy as sa
6+
from aiopg.sa.connection import SAConnection
7+
from sqlalchemy.ext.asyncio import AsyncConnection
88

9-
from ._protocols import AiopgConnection, DBConnection
109
from .models.groups import GroupType, groups
1110
from .models.products import products
1211

1312
# NOTE: outside this module, use instead packages/models-library/src/models_library/users.py
1413
_GroupID = int
1514

1615

17-
async def get_default_product_name(conn: DBConnection) -> str:
16+
async def get_default_product_name(conn: AsyncConnection | SAConnection) -> str:
1817
"""The first row in the table is considered as the default product
1918
2019
:: raises ValueError if undefined
@@ -31,15 +30,17 @@ async def get_default_product_name(conn: DBConnection) -> str:
3130

3231

3332
async def get_product_group_id(
34-
connection: DBConnection, product_name: str
33+
connection: SAConnection, product_name: str
3534
) -> _GroupID | None:
3635
group_id = await connection.scalar(
3736
sa.select(products.c.group_id).where(products.c.name == product_name)
3837
)
3938
return None if group_id is None else _GroupID(group_id)
4039

4140

42-
async def execute_get_or_create_product_group(conn, product_name: str) -> int:
41+
async def execute_get_or_create_product_group(
42+
conn: AsyncConnection, product_name: str
43+
) -> int:
4344
#
4445
# NOTE: Separated so it can be used in asyncpg and aiopg environs while both
4546
# coexist
@@ -73,7 +74,7 @@ async def execute_get_or_create_product_group(conn, product_name: str) -> int:
7374

7475

7576
async def get_or_create_product_group(
76-
connection: AiopgConnection, product_name: str
77+
connection: SAConnection, product_name: str
7778
) -> _GroupID:
7879
"""
7980
Returns group_id of a product. Creates it if undefined

0 commit comments

Comments
 (0)