Skip to content

Minor BugFix #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions logic_processes_layer/sub_processors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

__all__ = ("BaseSubprocessor", "CallResultT", "ContextT")

import dataclasses
import typing

from ..context import BaseProcessorContext
Expand All @@ -14,11 +13,34 @@
CallResultT = typing.TypeVar("CallResultT", bound=typing.Any)


@dataclasses.dataclass(unsafe_hash=True)
class BaseSubprocessor(typing.Generic[ContextT, CallResultT], metaclass=MetaSubprocessor):
context: ContextT = dataclasses.field(init=False, hash=False)
call_result: CallResultT = dataclasses.field(init=False, hash=False)
_context: ContextT | None = None
_call_result: CallResultT | None = None

def __call__(self) -> CallResultT:
msg = "Base subprocess call method is required to be implemented"
raise NotImplementedError(msg)

@property
def context(self) -> ContextT | None:
return self._context

@context.setter
def context(self, value: ContextT) -> None:
self._context = value # noqa: WPS601

@property
def call_result(self) -> CallResultT | None:
return self._call_result

@call_result.setter
def call_result(self, value: CallResultT) -> None:
self._call_result = value # noqa: WPS601

def __repr__(self):
context_str = f"{self.context!r}"
call_result_str = f"{self.call_result!r}"
return f"{self.__class__.__name__}({context_str=}, {call_result_str=})"

def __hash__(self):
return hash(f"{self.__class__.__name__}{id(self)}")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "logic_processes_layer"
version = "1.2025.01.09"
version = "1.2025.01.14"
requires-python = ">=3.8"
description = "Abstractions for create business logic"
readme = "README.md"
Expand Down
Loading