style: apply black formatting to src
All checks were successful
Test before pr merge / test-lint (pull_request) Successful in 7s
Test before pr merge / test (pull_request) Successful in 35s

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:
clu
2026-04-13 18:43:12 +02:00
parent ca58f636ee
commit cdca5614e8
9 changed files with 20 additions and 42 deletions

View File

@@ -42,8 +42,7 @@ class UserDao(DbModelDaoABC[User]):
permission_dao: PermissionDao = get_provider().get_service(PermissionDao)
p = await permission_dao.get_by_name(permission if isinstance(permission, str) else permission.value)
result = await self._db.select_map(
f"""
result = await self._db.select_map(f"""
SELECT COUNT(*) as count
FROM {TableManager.get("role_users")} ru
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 ru.deleted = FALSE
AND rp.deleted = FALSE;
"""
)
""")
if result is None or len(result) == 0:
return False
return result[0]["count"] > 0
async def get_permissions(self, user_id: int) -> list[Permission]:
result = await self._db.select_map(
f"""
result = await self._db.select_map(f"""
SELECT p.*
FROM {TableManager.get("permissions")} p
JOIN {TableManager.get("role_permissions")} rp ON p.id = rp.permissionId
@@ -68,6 +65,5 @@ class UserDao(DbModelDaoABC[User]):
WHERE ru.userId = {user_id}
AND rp.deleted = FALSE
AND ru.deleted = FALSE;
"""
)
""")
return [self._permissions.to_object(x) for x in result]

View File

@@ -50,8 +50,7 @@ class Structure:
if pyproject_path.exists():
return
content = textwrap.dedent(
f"""
content = textwrap.dedent(f"""
[build-system]
requires = ["setuptools>=70.1.0", "wheel", "build"]
build-backend = "setuptools.build_meta"
@@ -62,8 +61,7 @@ class Structure:
authors = [{{name="{project.author or ''}"}}]
license = "{project.license or ''}"
dependencies = [{', '.join([f'"{dep}"' for dep in project.dependencies])}]
"""
).lstrip()
""").lstrip()
pyproject_path.write_text(content)

View File

@@ -322,13 +322,11 @@ class DataAccessObjectABC(ABC, Generic[T_DBM]):
Touch the entry to update the last updated date
:return:
"""
await self._db.execute(
f"""
await self._db.execute(f"""
UPDATE {self._table_name}
SET updated = NOW()
WHERE {self.__primary_key} = {self._get_primary_key_value_sql(obj)};
"""
)
""")
async def touch_many_by_id(self, ids: list[Id]):
"""
@@ -338,13 +336,11 @@ class DataAccessObjectABC(ABC, Generic[T_DBM]):
if len(ids) == 0:
return
await self._db.execute(
f"""
await self._db.execute(f"""
UPDATE {self._table_name}
SET updated = NOW()
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:
allowed_fields = [x for x in self.__attributes.keys() if x not in self.__ignored_attributes]

View File

@@ -56,13 +56,11 @@ class ExternalDataTempTableBuilder:
values_str = ", ".join([f"{value}" for value in await self._value_getter()])
return textwrap.dedent(
f"""
return textwrap.dedent(f"""
DROP TABLE IF EXISTS {self._table_name};
CREATE TEMP TABLE {self._table_name} (
{", ".join([f"{k} {v}" for k, v in self._fields.items()])}
);
INSERT INTO {self._table_name} VALUES {values_str};
"""
)
""")

View File

@@ -84,19 +84,15 @@ class MigrationService(StartupTask):
async def _get_tables(self):
if ServerType == ServerTypes.POSTGRES:
return await self._db.select(
"""
return await self._db.select("""
SELECT tablename
FROM pg_tables
WHERE schemaname = 'public';
"""
)
""")
else:
return await self._db.select(
"""
return await self._db.select("""
SHOW TABLES;
"""
)
""")
async def _execute(self, migrations: list[Migration]):
result = await self._get_tables()

View File

@@ -3,7 +3,6 @@ from typing import TypeVar, Union, Literal, Any
from cpl.database.abc.db_model_abc import DbModelABC
T_DBM = TypeVar("T_DBM", bound=DbModelABC)
NumberFilterOperator = Literal[

View File

@@ -1,7 +1,6 @@
import contextvars
from contextlib import contextmanager
_current_provider = contextvars.ContextVar("current_provider", default=None)

View File

@@ -2,8 +2,7 @@ from starlette.responses import HTMLResponse
async def graphiql_endpoint(request):
return HTMLResponse(
"""
return HTMLResponse("""
<!DOCTYPE html>
<html>
<head>
@@ -65,5 +64,4 @@ async def graphiql_endpoint(request):
</script>
</body>
</html>
"""
)
""")

View File

@@ -3,8 +3,7 @@ from starlette.responses import Response, HTMLResponse
async def playground_endpoint(request: Request) -> Response:
return HTMLResponse(
"""
return HTMLResponse("""
<!DOCTYPE html>
<html>
<head>
@@ -25,5 +24,4 @@ async def playground_endpoint(request: Request) -> Response:
</script>
</body>
</html>
"""
)
""")