mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 18:15:28 +03:00
feat: impl docs (#4)
The entire public api is covered with documentation in two languages - Russian and English. the library now supports the latest three versions of python - 3.12, 3.13 and 3.14 minor design changes: now, when a Boolean flag is entered, its value is an empty string, not None. tests have been adapted to the supported versions of python, readmi has been redesigned in two languages, German is no longer available.
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
from argenta.di.integration import inject as inject
|
||||
from argenta.di.integration import FromDishka as FromDishka
|
||||
from argenta.di.integration import inject as inject
|
||||
|
||||
@@ -3,11 +3,10 @@ __all__ = ["inject", "setup_dishka", "FromDishka"]
|
||||
from typing import Any, Callable, TypeVar
|
||||
|
||||
from dishka import Container, FromDishka
|
||||
from dishka.integrations.base import wrap_injection, is_dishka_injected
|
||||
|
||||
from argenta.response import Response
|
||||
from argenta.app import App
|
||||
from dishka.integrations.base import is_dishka_injected, wrap_injection
|
||||
|
||||
from argenta.app.models import App
|
||||
from argenta.response.entity import Response
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
@@ -20,20 +19,18 @@ def inject(func: Callable[..., T]) -> Callable[..., T]:
|
||||
)
|
||||
|
||||
|
||||
def setup_dishka(app: App, *, auto_inject: bool = False) -> None:
|
||||
def setup_dishka(app: App, container: Container, *, auto_inject: bool = False) -> None:
|
||||
if auto_inject:
|
||||
_auto_inject_handlers(app)
|
||||
Response.patch_by_container(container)
|
||||
|
||||
|
||||
def _get_container_from_response(
|
||||
args: tuple[Any, ...], kwargs: dict[str, Any]
|
||||
) -> Container:
|
||||
def _get_container_from_response(args: tuple[Any, ...], kwargs: dict[str, Any]) -> Container:
|
||||
for arg in args:
|
||||
if isinstance(arg, Response):
|
||||
if hasattr(arg, "_dishka_container"):
|
||||
return arg._dishka_container # pyright: ignore[reportPrivateUsage]
|
||||
break
|
||||
|
||||
raise RuntimeError("dishka container not found in Response")
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
from argenta.orchestrator.argparser import ArgParser
|
||||
from dishka import Provider, provide, Scope
|
||||
__all__ = [
|
||||
"SystemProvider",
|
||||
]
|
||||
|
||||
from dishka import Provider, Scope, provide
|
||||
|
||||
from argenta.data_bridge import DataBridge
|
||||
from argenta.orchestrator.argparser import ArgParser
|
||||
from argenta.orchestrator.argparser.entity import ArgSpace
|
||||
|
||||
|
||||
class SystemProvider(Provider):
|
||||
def __init__(self, arg_parser: ArgParser):
|
||||
super().__init__()
|
||||
self._arg_parser: ArgParser = arg_parser
|
||||
@provide(scope=Scope.APP)
|
||||
def get_argspace(self, arg_parser: ArgParser) -> ArgSpace:
|
||||
return arg_parser.parsed_argspace
|
||||
|
||||
@provide(scope=Scope.APP)
|
||||
def get_argspace(self) -> ArgSpace:
|
||||
return self._arg_parser.parse_args()
|
||||
def get_data_bridge(self) -> DataBridge:
|
||||
return DataBridge()
|
||||
|
||||
Reference in New Issue
Block a user