Skip to content

Commit c0b99f1

Browse files
GefMarGefMar
and
GefMar
authored
Minor BugFix (#31) (#32)
Co-authored-by: GefMar <[email protected]>
1 parent 9fd2480 commit c0b99f1

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

logic_processes_layer/sub_processors/base.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

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

6-
import dataclasses
76
import typing
87

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

1615

17-
@dataclasses.dataclass(unsafe_hash=True)
1816
class BaseSubprocessor(typing.Generic[ContextT, CallResultT], metaclass=MetaSubprocessor):
19-
context: ContextT = dataclasses.field(init=False, hash=False)
20-
call_result: CallResultT = dataclasses.field(init=False, hash=False)
17+
_context: ContextT | None = None
18+
_call_result: CallResultT | None = None
2119

2220
def __call__(self) -> CallResultT:
2321
msg = "Base subprocess call method is required to be implemented"
2422
raise NotImplementedError(msg)
23+
24+
@property
25+
def context(self) -> ContextT | None:
26+
return self._context
27+
28+
@context.setter
29+
def context(self, value: ContextT) -> None:
30+
self._context = value # noqa: WPS601
31+
32+
@property
33+
def call_result(self) -> CallResultT | None:
34+
return self._call_result
35+
36+
@call_result.setter
37+
def call_result(self, value: CallResultT) -> None:
38+
self._call_result = value # noqa: WPS601
39+
40+
def __repr__(self):
41+
context_str = f"{self.context!r}"
42+
call_result_str = f"{self.call_result!r}"
43+
return f"{self.__class__.__name__}({context_str=}, {call_result_str=})"
44+
45+
def __hash__(self):
46+
return hash(f"{self.__class__.__name__}{id(self)}")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "logic_processes_layer"
7-
version = "1.2025.01.09"
7+
version = "1.2025.01.14"
88
requires-python = ">=3.8"
99
description = "Abstractions for create business logic"
1010
readme = "README.md"

0 commit comments

Comments
 (0)