File tree Expand file tree Collapse file tree
src/app/domain/value_objects Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99class ValueObject :
1010 """
1111 Base class for immutable value objects (VO) in domain.
12- Defined by its attributes, which must themselves be immutable.
12+ Defined by its instance attributes, which must themselves be immutable.
1313 For simple cases where only type distinction is required,
1414 consider using `typing.NewType` instead of subclassing this class.
15+
16+ Warning: due to mismatch between typing rules and runtime behavior
17+ for `Final[ClassVar[T]]`, using `__slots__` in subclasses is not
18+ recommended — such class constants are turned into `member_descriptor`
19+ at runtime instead of preserving their declared values.
20+
21+ Note: I considered using plain `ClassVar[T]` for class constants
22+ (as `ClassVar[Final[T]]` currently has no semantic meaning anyway)
23+ which would immediately resolve the slots compatibility and `fields()`
24+ behavior issues. However, I chose to prioritize correct typing
25+ semantics with `Final[ClassVar[T]]` and observe how this inconsistency
26+ between typing rules and runtime behavior gets resolved.
27+
28+ https://github.com/python/cpython/issues/89547
29+ https://github.com/python/mypy/issues/19607
1530 """
1631
1732 def __post_init__ (self ) -> None :
You can’t perform that action at this time.
0 commit comments