Update stubs

This commit is contained in:
Trinh Anh Ngoc
2024-05-12 21:54:25 +07:00
parent cd23e1718e
commit 6fbe09adcf
8 changed files with 117 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
from . import builder as builder
from . import components as components
from . import core as core
from . import models as models

View File

@@ -0,0 +1,16 @@
from typing import Iterable
from ...models import AbstractModel
from .core import DEFAULT_CACHE_SIZE as DEFAULT_CACHE_SIZE
from .core import ComponentRegistry as ComponentRegistry
class ComponentBuilder(AbstractModel):
def build_registry(
self,
components_registry: ComponentRegistry,
states: Iterable[str] | None = None,
exclude_addons: Iterable[str] | None = None,
) -> None: ...
def load_components(
self, module: str, components_registry: ComponentRegistry | None = None
) -> None: ...

View File

@@ -0,0 +1 @@
from . import base as base

View File

@@ -0,0 +1,3 @@
from ..core import AbstractComponent as AbstractComponent
class BaseComponent(AbstractComponent): ...

View File

@@ -0,0 +1,80 @@
from typing import Any, Optional
from ...api import Environment
from ...models import BaseModel
from .exception import NoComponentError as NoComponentError
from .exception import SeveralComponentError as SeveralComponentError
from .models.collection import Collection
DEFAULT_CACHE_SIZE: int
class ComponentDatabases(dict): ...
class ComponentRegistry:
ready: bool
def __init__(self, cachesize=...) -> None: ...
def __getitem__(self, key): ...
def __setitem__(self, key, value) -> None: ...
def __contains__(self, key) -> bool: ...
def get(self, key, default: Any | None = None): ...
def __iter__(self): ...
def load_components(self, module) -> None: ...
def lookup(
self,
collection_name: str | None = None,
usage: str | None = None,
model_name: str | None = None,
): ...
class WorkContext:
collection: Collection
model_name: str
model: BaseModel
components_registry: ComponentRegistry
def __init__(
self,
model_name: str | None = None,
collection: Optional[Collection] = None,
components_registry: ComponentRegistry | None = None,
**kwargs
) -> None: ...
@property
def env(self) -> Environment: ...
def work_on(
self, model_name: str | None = None, collection: Optional[Collection] = None
) -> WorkContext: ...
def component_by_name(
self, name: str, model_name: str | BaseModel | None = None
) -> Component: ...
def component(
self, usage: str | None = None, model_name: str | BaseModel | None = None, **kw
) -> Component: ...
def many_components(
self, usage: str | None = None, model_name: str | BaseModel | None = None, **kw
) -> list[Component]: ...
class MetaComponent(type):
def __init__(cls: type[AbstractComponent], name, bases, attrs) -> None: ...
@property
def apply_on_models(cls: type[AbstractComponent]): ...
class AbstractComponent(metaclass=MetaComponent):
work: WorkContext
def __init__(self, work_context: WorkContext) -> None: ...
@property
def collection(self) -> Collection: ...
@property
def env(self) -> Environment: ...
@property
def model(self) -> BaseModel: ...
def component_by_name(
self, name: str, model_name: str | BaseModel | None = None
) -> Component: ...
def component(
self, usage: str | None = None, model_name: str | BaseModel | None = None, **kw
) -> Component: ...
def many_components(
self, usage: str | None = None, model_name: str | BaseModel | None = None, **kw
) -> list[Component]: ...
class Component(AbstractComponent): ...

View File

@@ -0,0 +1,3 @@
class ComponentException(Exception): ...
class NoComponentError(ComponentException): ...
class SeveralComponentError(ComponentException): ...

View File

@@ -0,0 +1 @@
from . import collection as collection

View File

@@ -0,0 +1,9 @@
from contextlib import contextmanager
from typing import Iterator
from ....models import AbstractModel
from ..core import WorkContext
class Collection(AbstractModel):
@contextmanager
def work_on(self, model_name: str, **kwargs) -> Iterator[WorkContext]: ...