Simplify working with the Placeholder objects used by the transaction feature.
Requested solution
We should investigate how to simplify working with the Placeholder objects used by the transaction feature (e.g., removing the need to call placeholder.unwrap() to obtain the underlying object).
Proposed implementation approach
@AdrianoKF has a quick prototype based on the wrapt package, which might serve as a starting point:
from dataclasses import dataclass
from typing import Generic, TypeVar
import wrapt
T = TypeVar("T")
@dataclass
class Data:
message: str
class Future(Generic[T], Data, wrapt.ObjectProxy):
@property
def is_filled(self) -> bool:
return self.__wrapped__ is not None
a = Data("hello")
wrapped = Future(a)
print(a, wrapped)
print(a.message, wrapped.message)
print(wrapped.is_filled)
print(a is wrapped)
print("-" * 80)
empty_wrapper = Future[Data](None)
print(empty_wrapper.is_filled)
Motivation
Simplify working with the
Placeholder
objects used by the transaction feature.Requested solution
We should investigate how to simplify working with the
Placeholder
objects used by the transaction feature (e.g., removing the need to callplaceholder.unwrap()
to obtain the underlying object).Proposed implementation approach
@AdrianoKF has a quick prototype based on the
wrapt
package, which might serve as a starting point:Resources:
wrapt — wrapt 1.16.0 documentation
Additional context
No response
Related GitHub issue(s)
No response
Acceptance Criteria (mandatory to start implementation)
Placeholder
class.Definition of Done (mandatory to close an issue as completed)