Skip to content

Commit b0d50e7

Browse files
authored
Merge pull request #104 from python-ellar/app_context_default_async
App context default async
2 parents f372e4b + 8e29b18 commit b0d50e7

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

ellar_cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Ellar CLI Tool for Scaffolding Ellar Projects, Modules and also running Ellar Commands"""
22

3-
__version__ = "0.4.2b1"
3+
__version__ = "0.4.2"

ellar_cli/click/group.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import inspect
12
import typing as t
23

34
import click
45
from ellar.app import AppFactory
56
from ellar.common.constants import MODULE_METADATA
67
from ellar.core import ModuleBase, ModuleSetup, reflector
8+
from ellar.threading import run_as_sync
79

810
from ellar_cli.constants import ELLAR_META
911
from ellar_cli.service import EllarCLIService, EllarCLIServiceWithPyProject
@@ -30,6 +32,9 @@ def command( # type:ignore[override]
3032
wrap_for_ctx = kwargs.pop("with_injector_context", True)
3133

3234
def decorator(f: t.Callable) -> t.Any:
35+
if inspect.iscoroutinefunction(f):
36+
f = run_as_sync(f)
37+
3338
if wrap_for_ctx:
3439
f = with_injector_context(f)
3540
return super(AppContextGroup, self).command(*args, **kwargs)(f)

ellar_cli/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def version_callback(ctx: click.Context, _: t.Any, value: bool) -> None:
2525
raise click.Exit(0)
2626

2727

28-
def create_ellar_cli(app_import_string: t.Optional[str] = None) -> click.Group:
28+
def create_ellar_cli(app_import_string: t.Optional[str] = None) -> EllarCommandGroup:
2929
@click.group(
3030
name="Ellar CLI Tool... ",
3131
cls=EllarCommandGroup,

ellar_cli/service/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def _import_and_validate_application(
179179
)
180180

181181
if is_callable:
182-
app = app() # type:ignore[call-arg]
182+
app = app()
183183

184184
if not isinstance(app, App):
185185
raise EllarCLIException(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ classifiers = [
4242
dependencies = [
4343
# exclude 0.11.2 and 0.11.3 due to https://github.com/sdispater/tomlkit/issues/225
4444
"tomlkit >=0.11.1,<1.0.0,!=0.11.2,!=0.11.3",
45-
"ellar >= 0.8b1",
45+
"ellar >= 0.8.1",
4646
"uvicorn[standard] == 0.30.4",
4747
"click >= 8.1.7",
4848
]

0 commit comments

Comments
 (0)