diff --git a/src/auth/cpl/auth/schema/_administration/user_dao.py b/src/auth/cpl/auth/schema/_administration/user_dao.py index 206ab553..ef6b0997 100644 --- a/src/auth/cpl/auth/schema/_administration/user_dao.py +++ b/src/auth/cpl/auth/schema/_administration/user_dao.py @@ -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] diff --git a/src/cli/cpl/cli/utils/structure.py b/src/cli/cpl/cli/utils/structure.py index 34472f3c..72793636 100644 --- a/src/cli/cpl/cli/utils/structure.py +++ b/src/cli/cpl/cli/utils/structure.py @@ -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) diff --git a/src/database/cpl/database/abc/data_access_object_abc.py b/src/database/cpl/database/abc/data_access_object_abc.py index 7f1e235b..1b358276 100644 --- a/src/database/cpl/database/abc/data_access_object_abc.py +++ b/src/database/cpl/database/abc/data_access_object_abc.py @@ -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] diff --git a/src/database/cpl/database/external_data_temp_table_builder.py b/src/database/cpl/database/external_data_temp_table_builder.py index 588630b4..bb84c670 100644 --- a/src/database/cpl/database/external_data_temp_table_builder.py +++ b/src/database/cpl/database/external_data_temp_table_builder.py @@ -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}; - """ - ) + """) diff --git a/src/database/cpl/database/service/migration_service.py b/src/database/cpl/database/service/migration_service.py index 0f5b5916..006eb085 100644 --- a/src/database/cpl/database/service/migration_service.py +++ b/src/database/cpl/database/service/migration_service.py @@ -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() diff --git a/src/database/cpl/database/typing.py b/src/database/cpl/database/typing.py index c3b7385a..080e66d9 100644 --- a/src/database/cpl/database/typing.py +++ b/src/database/cpl/database/typing.py @@ -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[ diff --git a/src/dependency/cpl/dependency/context.py b/src/dependency/cpl/dependency/context.py index f4d8a331..a2074e20 100644 --- a/src/dependency/cpl/dependency/context.py +++ b/src/dependency/cpl/dependency/context.py @@ -1,7 +1,6 @@ import contextvars from contextlib import contextmanager - _current_provider = contextvars.ContextVar("current_provider", default=None) diff --git a/src/graphql/cpl/graphql/_endpoints/graphiql.py b/src/graphql/cpl/graphql/_endpoints/graphiql.py index a369fd64..4c1266df 100644 --- a/src/graphql/cpl/graphql/_endpoints/graphiql.py +++ b/src/graphql/cpl/graphql/_endpoints/graphiql.py @@ -2,8 +2,7 @@ from starlette.responses import HTMLResponse async def graphiql_endpoint(request): - return HTMLResponse( - """ + return HTMLResponse(""" @@ -65,5 +64,4 @@ async def graphiql_endpoint(request): - """ - ) + """) diff --git a/src/graphql/cpl/graphql/_endpoints/playground.py b/src/graphql/cpl/graphql/_endpoints/playground.py index 969cd506..68e59fdf 100644 --- a/src/graphql/cpl/graphql/_endpoints/playground.py +++ b/src/graphql/cpl/graphql/_endpoints/playground.py @@ -3,8 +3,7 @@ from starlette.responses import Response, HTMLResponse async def playground_endpoint(request: Request) -> Response: - return HTMLResponse( - """ + return HTMLResponse(""" @@ -25,5 +24,4 @@ async def playground_endpoint(request: Request) -> Response: - """ - ) + """)