Skip to content

Commit 1e56534

Browse files
committed
refactored all packages and clearly depend flow of dependencies among packages
1 parent f187293 commit 1e56534

File tree

270 files changed

+1544
-1347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+1544
-1347
lines changed

ellar/cache/backends/local_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from anyio import Lock
88

9-
from ellar.helper.event_loop import get_or_create_eventloop
9+
from ellar.common.helper.event_loop import get_or_create_eventloop
1010

1111
from ..interface import IBaseCacheBackendAsync
1212
from ..make_key_decorator import make_key_decorator, make_key_decorator_and_validate

ellar/cache/backends/redis/backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import typing as t
33
from abc import ABC
44

5-
from ellar.helper.event_loop import get_or_create_eventloop
5+
from ellar.common.helper.event_loop import get_or_create_eventloop
66

77
try:
88
from redis.asyncio import Redis # type: ignore

ellar/cache/decorator.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
from functools import wraps
44

55
from ellar.cache.interface import ICacheService
6-
from ellar.common import Context, Provide, extra_args
7-
from ellar.core import ExecutionContext, IExecutionContext
8-
from ellar.core.params import ExtraEndpointArg
9-
from ellar.helper import is_async_callable
6+
from ellar.common import Context, IExecutionContext, Provide, extra_args
7+
from ellar.common.helper import is_async_callable
8+
from ellar.common.params import ExtraEndpointArg
109

1110

1211
class _CacheDecorator:
@@ -41,10 +40,14 @@ def __init__(
4140

4241
# create extra args
4342
self._cache_service_arg = ExtraEndpointArg(
44-
name=f"cache_service_{uuid.uuid4().hex[:4]}", annotation=ICacheService, default_value=Provide() # type: ignore
43+
name=f"cache_service_{uuid.uuid4().hex[:4]}",
44+
annotation=ICacheService, # type:ignore[misc]
45+
default_value=Provide(),
4546
)
4647
self._context_arg = ExtraEndpointArg(
47-
name=f"route_context_{uuid.uuid4().hex[:4]}", annotation=IExecutionContext, default_value=Context() # type: ignore
48+
name=f"route_context_{uuid.uuid4().hex[:4]}",
49+
annotation=IExecutionContext, # type:ignore[misc]
50+
default_value=Context(),
4851
)
4952
# apply extra_args to endpoint
5053
extra_args(self._cache_service_arg, self._context_arg)(func)
@@ -129,9 +132,7 @@ def cache(
129132
key_prefix: str = "",
130133
version: str = None,
131134
backend: str = "default",
132-
make_key_callback: t.Callable[
133-
[t.Union[ExecutionContext, IExecutionContext], str], str
134-
] = None,
135+
make_key_callback: t.Callable[[IExecutionContext, str], str] = None,
135136
) -> t.Callable:
136137
"""
137138

ellar/cache/make_key_decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import functools
22
import typing as t
33

4-
from ellar.helper import is_async_callable
4+
from ellar.common.helper import is_async_callable
55

66
if t.TYPE_CHECKING: # pragma: no cover
77
from .model import BaseCacheBackend

ellar/cache/module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import typing as t
22

3-
from ellar.common import Module
4-
from ellar.core import Config, DynamicModule, IModuleSetup, ModuleBase, ModuleSetup
3+
from ellar.common import IModuleSetup, Module
4+
from ellar.core import Config, DynamicModule, ModuleBase, ModuleSetup
55
from ellar.di import ProviderConfig
66

77
from .interface import ICacheService

ellar/common/__init__.py

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import typing as t
22

3-
from ellar.core.params.params import Param, ParamTypes
4-
from ellar.core.routing import ModuleRouter
3+
from starlette.exceptions import WebSocketException
54

5+
from .commands import EllarTyper, command
6+
from .datastructures import UploadFile
67
from .decorators import (
78
Controller,
89
Guards,
910
Module,
1011
Version,
11-
command,
1212
exception_handler,
1313
extra_args,
1414
file,
@@ -20,6 +20,52 @@
2020
template_filter,
2121
template_global,
2222
)
23+
from .exceptions import (
24+
APIException,
25+
AuthenticationFailed,
26+
HTTPException,
27+
MethodNotAllowed,
28+
NotAcceptable,
29+
NotAuthenticated,
30+
NotFound,
31+
PermissionDenied,
32+
UnsupportedMediaType,
33+
)
34+
from .interfaces import (
35+
IExceptionHandler,
36+
IExceptionMiddlewareService,
37+
IExecutionContext,
38+
IExecutionContextFactory,
39+
IHostContext,
40+
IHostContextFactory,
41+
IHTTPConnectionContextFactory,
42+
IHTTPHostContext,
43+
IModuleSetup,
44+
IModuleTemplateLoader,
45+
IResponseModel,
46+
IWebSocketContextFactory,
47+
IWebSocketHostContext,
48+
)
49+
from .models import (
50+
BaseAPIKey,
51+
BaseAuthGuard,
52+
BaseHttpAuth,
53+
ControllerBase,
54+
ControllerType,
55+
GuardCanActivate,
56+
)
57+
from .params.params import ParamFieldInfo as Param, ParamTypes
58+
from .responses import (
59+
FileResponse,
60+
HTMLResponse,
61+
JSONResponse,
62+
ORJSONResponse,
63+
PlainTextResponse,
64+
RedirectResponse,
65+
Response,
66+
StreamingResponse,
67+
UJSONResponse,
68+
)
2369
from .routing import (
2470
Body,
2571
Context,
@@ -29,13 +75,13 @@
2975
Header,
3076
Host,
3177
Http,
78+
ModuleRouter,
3279
Path,
3380
Provide,
3481
Query,
3582
Req,
3683
Res,
3784
Session,
38-
UploadFile,
3985
Ws,
4086
WsBody,
4187
delete,
@@ -49,8 +95,32 @@
4995
trace,
5096
ws_route,
5197
)
98+
from .serializer import DataclassSerializer, Serializer, serialize_object
99+
from .templating import TemplateResponse, render_template, render_template_string
52100

53101
__all__ = [
102+
"ControllerBase",
103+
"serialize_object",
104+
"ControllerType",
105+
"BaseAuthGuard",
106+
"BaseAPIKey",
107+
"BaseHttpAuth",
108+
"GuardCanActivate",
109+
"EllarTyper",
110+
"Serializer",
111+
"DataclassSerializer",
112+
"WebSocketException",
113+
"APIException",
114+
"AuthenticationFailed",
115+
"NotAuthenticated",
116+
"NotFound",
117+
"NotAcceptable",
118+
"PermissionDenied",
119+
"HTTPException",
120+
"UnsupportedMediaType",
121+
"MethodNotAllowed",
122+
"render_template",
123+
"render_template_string",
54124
"command",
55125
"ModuleRouter",
56126
"render",
@@ -96,6 +166,29 @@
96166
"UploadFile",
97167
"file",
98168
"extra_args",
169+
"JSONResponse",
170+
"UJSONResponse",
171+
"ORJSONResponse",
172+
"StreamingResponse",
173+
"HTMLResponse",
174+
"FileResponse",
175+
"PlainTextResponse",
176+
"RedirectResponse",
177+
"TemplateResponse",
178+
"Response",
179+
"IHostContext",
180+
"IExecutionContextFactory",
181+
"IExecutionContext",
182+
"IHostContextFactory",
183+
"IHTTPHostContext",
184+
"IWebSocketContextFactory",
185+
"IWebSocketHostContext",
186+
"IHTTPConnectionContextFactory",
187+
"IExceptionMiddlewareService",
188+
"IExceptionHandler",
189+
"IModuleSetup",
190+
"IResponseModel",
191+
"IModuleTemplateLoader",
99192
]
100193

101194

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from .base import EllarTyper
2+
from .decorator import command
23

34
__all__ = [
45
"EllarTyper",
6+
"command",
57
]
File renamed without changes.

ellar/common/decorators/command.py renamed to ellar/common/commands/decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typer.core import TyperCommand
55
from typer.models import CommandFunctionType, CommandInfo
66

7-
from ellar.constants import CALLABLE_COMMAND_INFO
7+
from ellar.common.constants import CALLABLE_COMMAND_INFO
88

99

1010
@t.no_type_check
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from .cache_properties import cached_property
2-
from .contextmanager import asynccontextmanager
32
from .dict import AttributeDict, AttributeDictAccessMixin, DataMapper
43
from .emails import EmailStr
54

@@ -8,6 +7,5 @@
87
"EmailStr",
98
"AttributeDictAccessMixin",
109
"DataMapper",
11-
"asynccontextmanager",
1210
"AttributeDict",
1311
]

0 commit comments

Comments
 (0)