Fixed formatting
All checks were successful
Build on push / prepare (push) Successful in 9s
Build on push / core (push) Successful in 17s
Build on push / query (push) Successful in 17s
Build on push / dependency (push) Successful in 17s
Build on push / translation (push) Successful in 14s
Build on push / application (push) Successful in 18s
Build on push / database (push) Successful in 17s
Build on push / mail (push) Successful in 18s
Build on push / auth (push) Successful in 13s
Build on push / api (push) Successful in 17s
Test before pr merge / test-lint (pull_request) Successful in 5s
All checks were successful
Build on push / prepare (push) Successful in 9s
Build on push / core (push) Successful in 17s
Build on push / query (push) Successful in 17s
Build on push / dependency (push) Successful in 17s
Build on push / translation (push) Successful in 14s
Build on push / application (push) Successful in 18s
Build on push / database (push) Successful in 17s
Build on push / mail (push) Successful in 18s
Build on push / auth (push) Successful in 13s
Build on push / api (push) Successful in 17s
Test before pr merge / test-lint (pull_request) Successful in 5s
This commit is contained in:
@@ -1,20 +1,26 @@
|
||||
from cpl.dependency.service_collection import ServiceCollection as _ServiceCollection
|
||||
|
||||
|
||||
def add_api(collection: _ServiceCollection):
|
||||
try:
|
||||
from cpl.database import mysql
|
||||
|
||||
collection.add_module(mysql)
|
||||
except ImportError as e:
|
||||
from cpl.core.errors import dependency_error
|
||||
|
||||
dependency_error("cpl-database", e)
|
||||
|
||||
try:
|
||||
from cpl import auth
|
||||
from cpl.auth import permission
|
||||
|
||||
collection.add_module(auth)
|
||||
collection.add_module(permission)
|
||||
except ImportError as e:
|
||||
from cpl.core.errors import dependency_error
|
||||
|
||||
dependency_error("cpl-auth", e)
|
||||
|
||||
|
||||
_ServiceCollection.with_module(add_api, __name__)
|
||||
@@ -9,6 +9,7 @@ from cpl.api.middleware.request import get_request
|
||||
|
||||
_logger = APILogger(__name__)
|
||||
|
||||
|
||||
class LoggingMiddleware(ASGIMiddleware):
|
||||
|
||||
def __init__(self, app):
|
||||
|
||||
@@ -175,11 +175,7 @@ class WebApp(ApplicationABC):
|
||||
# )
|
||||
|
||||
config = uvicorn.Config(
|
||||
app,
|
||||
host=self._api_settings.host,
|
||||
port=self._api_settings.port,
|
||||
log_config=None,
|
||||
loop="asyncio"
|
||||
app, host=self._api_settings.host, port=self._api_settings.port, log_config=None, loop="asyncio"
|
||||
)
|
||||
server = uvicorn.Server(config)
|
||||
await server.serve()
|
||||
|
||||
@@ -24,10 +24,9 @@ class ApplicationABC(ABC):
|
||||
@abstractmethod
|
||||
def __init__(self, services: ServiceProviderABC, required_modules: list[str | object] = None):
|
||||
self._services = services
|
||||
self._required_modules = [
|
||||
x.__name__ if not isinstance(x, str) else x
|
||||
for x in required_modules
|
||||
] if required_modules else []
|
||||
self._required_modules = (
|
||||
[x.__name__ if not isinstance(x, str) else x for x in required_modules] if required_modules else []
|
||||
)
|
||||
|
||||
@property
|
||||
def required_modules(self) -> list[str]:
|
||||
|
||||
@@ -59,6 +59,7 @@ def add_auth(collection: _ServiceCollection):
|
||||
migration_service.with_directory(os.path.join(os.path.dirname(os.path.realpath(__file__)), "scripts/mysql"))
|
||||
except ImportError as e:
|
||||
from cpl.core.console import Console
|
||||
|
||||
Console.error("cpl-database is not installed", str(e))
|
||||
|
||||
|
||||
@@ -69,6 +70,7 @@ def add_permission(collection: _ServiceCollection):
|
||||
|
||||
try:
|
||||
from cpl.database.abc.data_seeder_abc import DataSeederABC
|
||||
|
||||
collection.add_singleton(DataSeederABC, PermissionSeeder)
|
||||
PermissionsRegistry.with_enum(Permissions)
|
||||
except ImportError as e:
|
||||
|
||||
@@ -9,6 +9,7 @@ from cpl.database.model import DatabaseSettings
|
||||
|
||||
_logger = DBLogger(__name__)
|
||||
|
||||
|
||||
class MySQLPool:
|
||||
|
||||
def __init__(self, database_settings: DatabaseSettings):
|
||||
|
||||
@@ -115,6 +115,7 @@ class ServiceProviderABC(ABC):
|
||||
return functools.partial(cls.inject)
|
||||
|
||||
if iscoroutinefunction(f):
|
||||
|
||||
@functools.wraps(f)
|
||||
async def async_inner(*args, **kwargs):
|
||||
if cls._provider is None:
|
||||
@@ -132,4 +133,5 @@ class ServiceProviderABC(ABC):
|
||||
|
||||
injection = [x for x in cls._provider._build_by_signature(signature(f)) if x is not None]
|
||||
return f(*args, *injection, **kwargs)
|
||||
|
||||
return inner
|
||||
|
||||
Reference in New Issue
Block a user