Source code for ascetic_ddd.faker.domain.specification.interfaces
import typing
from ascetic_ddd.session.interfaces import ISession
__all__ = (
'ISpecificationVisitor',
'ISpecificationVisitable',
'ISpecification',
'IResolvableSpecification',
)
T = typing.TypeVar("T", covariant=True)
[docs]
class ISpecificationVisitor(typing.Protocol):
[docs]
def visit_query_specification(
self,
query: typing.Any, # IQueryOperator
aggregate_provider_accessor: typing.Callable[[], typing.Any] | None = None
):
...
[docs]
def visit_empty_specification(self):
...
[docs]
def visit_scope_specification(self, scope: typing.Hashable):
...
[docs]
class ISpecificationVisitable(typing.Protocol[T]):
[docs]
def accept(self, visitor: ISpecificationVisitor):
...
[docs]
class ISpecification(ISpecificationVisitable[T], typing.Protocol[T]):
def __str__(self) -> str:
...
def __hash__(self) -> int:
...
def __eq__(self, other: object) -> bool:
...
[docs]
async def is_satisfied_by(self, session: ISession, obj: T) -> bool:
...
[docs]
class IResolvableSpecification(ISpecification[T], typing.Protocol[T]):
"""Interface for a specification that requires pre-resolve."""
[docs]
async def resolve_nested(self, session: ISession) -> None:
...