style: apply black formatting to src
Auto-formatted 9 files that were failing the black lint check. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,8 +42,7 @@ class UserDao(DbModelDaoABC[User]):
|
|||||||
|
|
||||||
permission_dao: PermissionDao = get_provider().get_service(PermissionDao)
|
permission_dao: PermissionDao = get_provider().get_service(PermissionDao)
|
||||||
p = await permission_dao.get_by_name(permission if isinstance(permission, str) else permission.value)
|
p = await permission_dao.get_by_name(permission if isinstance(permission, str) else permission.value)
|
||||||
result = await self._db.select_map(
|
result = await self._db.select_map(f"""
|
||||||
f"""
|
|
||||||
SELECT COUNT(*) as count
|
SELECT COUNT(*) as count
|
||||||
FROM {TableManager.get("role_users")} ru
|
FROM {TableManager.get("role_users")} ru
|
||||||
JOIN {TableManager.get("role_permissions")} rp ON ru.roleId = rp.roleId
|
JOIN {TableManager.get("role_permissions")} rp ON ru.roleId = rp.roleId
|
||||||
@@ -51,16 +50,14 @@ class UserDao(DbModelDaoABC[User]):
|
|||||||
AND rp.permissionId = {p.id}
|
AND rp.permissionId = {p.id}
|
||||||
AND ru.deleted = FALSE
|
AND ru.deleted = FALSE
|
||||||
AND rp.deleted = FALSE;
|
AND rp.deleted = FALSE;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
if result is None or len(result) == 0:
|
if result is None or len(result) == 0:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return result[0]["count"] > 0
|
return result[0]["count"] > 0
|
||||||
|
|
||||||
async def get_permissions(self, user_id: int) -> list[Permission]:
|
async def get_permissions(self, user_id: int) -> list[Permission]:
|
||||||
result = await self._db.select_map(
|
result = await self._db.select_map(f"""
|
||||||
f"""
|
|
||||||
SELECT p.*
|
SELECT p.*
|
||||||
FROM {TableManager.get("permissions")} p
|
FROM {TableManager.get("permissions")} p
|
||||||
JOIN {TableManager.get("role_permissions")} rp ON p.id = rp.permissionId
|
JOIN {TableManager.get("role_permissions")} rp ON p.id = rp.permissionId
|
||||||
@@ -68,6 +65,5 @@ class UserDao(DbModelDaoABC[User]):
|
|||||||
WHERE ru.userId = {user_id}
|
WHERE ru.userId = {user_id}
|
||||||
AND rp.deleted = FALSE
|
AND rp.deleted = FALSE
|
||||||
AND ru.deleted = FALSE;
|
AND ru.deleted = FALSE;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
return [self._permissions.to_object(x) for x in result]
|
return [self._permissions.to_object(x) for x in result]
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ class Structure:
|
|||||||
if pyproject_path.exists():
|
if pyproject_path.exists():
|
||||||
return
|
return
|
||||||
|
|
||||||
content = textwrap.dedent(
|
content = textwrap.dedent(f"""
|
||||||
f"""
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools>=70.1.0", "wheel", "build"]
|
requires = ["setuptools>=70.1.0", "wheel", "build"]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
@@ -62,8 +61,7 @@ class Structure:
|
|||||||
authors = [{{name="{project.author or ''}"}}]
|
authors = [{{name="{project.author or ''}"}}]
|
||||||
license = "{project.license or ''}"
|
license = "{project.license or ''}"
|
||||||
dependencies = [{', '.join([f'"{dep}"' for dep in project.dependencies])}]
|
dependencies = [{', '.join([f'"{dep}"' for dep in project.dependencies])}]
|
||||||
"""
|
""").lstrip()
|
||||||
).lstrip()
|
|
||||||
|
|
||||||
pyproject_path.write_text(content)
|
pyproject_path.write_text(content)
|
||||||
|
|
||||||
|
|||||||
@@ -322,13 +322,11 @@ class DataAccessObjectABC(ABC, Generic[T_DBM]):
|
|||||||
Touch the entry to update the last updated date
|
Touch the entry to update the last updated date
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
await self._db.execute(
|
await self._db.execute(f"""
|
||||||
f"""
|
|
||||||
UPDATE {self._table_name}
|
UPDATE {self._table_name}
|
||||||
SET updated = NOW()
|
SET updated = NOW()
|
||||||
WHERE {self.__primary_key} = {self._get_primary_key_value_sql(obj)};
|
WHERE {self.__primary_key} = {self._get_primary_key_value_sql(obj)};
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
async def touch_many_by_id(self, ids: list[Id]):
|
async def touch_many_by_id(self, ids: list[Id]):
|
||||||
"""
|
"""
|
||||||
@@ -338,13 +336,11 @@ class DataAccessObjectABC(ABC, Generic[T_DBM]):
|
|||||||
if len(ids) == 0:
|
if len(ids) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
await self._db.execute(
|
await self._db.execute(f"""
|
||||||
f"""
|
|
||||||
UPDATE {self._table_name}
|
UPDATE {self._table_name}
|
||||||
SET updated = NOW()
|
SET updated = NOW()
|
||||||
WHERE {self.__primary_key} IN ({", ".join([str(x) for x in ids])});
|
WHERE {self.__primary_key} IN ({", ".join([str(x) for x in ids])});
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
async def _build_create_statement(self, obj: T_DBM, skip_editor=False) -> str:
|
async def _build_create_statement(self, obj: T_DBM, skip_editor=False) -> str:
|
||||||
allowed_fields = [x for x in self.__attributes.keys() if x not in self.__ignored_attributes]
|
allowed_fields = [x for x in self.__attributes.keys() if x not in self.__ignored_attributes]
|
||||||
|
|||||||
@@ -56,13 +56,11 @@ class ExternalDataTempTableBuilder:
|
|||||||
|
|
||||||
values_str = ", ".join([f"{value}" for value in await self._value_getter()])
|
values_str = ", ".join([f"{value}" for value in await self._value_getter()])
|
||||||
|
|
||||||
return textwrap.dedent(
|
return textwrap.dedent(f"""
|
||||||
f"""
|
|
||||||
DROP TABLE IF EXISTS {self._table_name};
|
DROP TABLE IF EXISTS {self._table_name};
|
||||||
CREATE TEMP TABLE {self._table_name} (
|
CREATE TEMP TABLE {self._table_name} (
|
||||||
{", ".join([f"{k} {v}" for k, v in self._fields.items()])}
|
{", ".join([f"{k} {v}" for k, v in self._fields.items()])}
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO {self._table_name} VALUES {values_str};
|
INSERT INTO {self._table_name} VALUES {values_str};
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|||||||
@@ -84,19 +84,15 @@ class MigrationService(StartupTask):
|
|||||||
|
|
||||||
async def _get_tables(self):
|
async def _get_tables(self):
|
||||||
if ServerType == ServerTypes.POSTGRES:
|
if ServerType == ServerTypes.POSTGRES:
|
||||||
return await self._db.select(
|
return await self._db.select("""
|
||||||
"""
|
|
||||||
SELECT tablename
|
SELECT tablename
|
||||||
FROM pg_tables
|
FROM pg_tables
|
||||||
WHERE schemaname = 'public';
|
WHERE schemaname = 'public';
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
return await self._db.select(
|
return await self._db.select("""
|
||||||
"""
|
|
||||||
SHOW TABLES;
|
SHOW TABLES;
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
||||||
async def _execute(self, migrations: list[Migration]):
|
async def _execute(self, migrations: list[Migration]):
|
||||||
result = await self._get_tables()
|
result = await self._get_tables()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from typing import TypeVar, Union, Literal, Any
|
|||||||
|
|
||||||
from cpl.database.abc.db_model_abc import DbModelABC
|
from cpl.database.abc.db_model_abc import DbModelABC
|
||||||
|
|
||||||
|
|
||||||
T_DBM = TypeVar("T_DBM", bound=DbModelABC)
|
T_DBM = TypeVar("T_DBM", bound=DbModelABC)
|
||||||
|
|
||||||
NumberFilterOperator = Literal[
|
NumberFilterOperator = Literal[
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import contextvars
|
import contextvars
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
|
|
||||||
_current_provider = contextvars.ContextVar("current_provider", default=None)
|
_current_provider = contextvars.ContextVar("current_provider", default=None)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ from starlette.responses import HTMLResponse
|
|||||||
|
|
||||||
|
|
||||||
async def graphiql_endpoint(request):
|
async def graphiql_endpoint(request):
|
||||||
return HTMLResponse(
|
return HTMLResponse("""
|
||||||
"""
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -65,5 +64,4 @@ async def graphiql_endpoint(request):
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ from starlette.responses import Response, HTMLResponse
|
|||||||
|
|
||||||
|
|
||||||
async def playground_endpoint(request: Request) -> Response:
|
async def playground_endpoint(request: Request) -> Response:
|
||||||
return HTMLResponse(
|
return HTMLResponse("""
|
||||||
"""
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -25,5 +24,4 @@ async def playground_endpoint(request: Request) -> Response:
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user