From 320e96eec68de9add18d55ade17eea2fe8bc439d Mon Sep 17 00:00:00 2001 From: Nik Belyaev Date: Mon, 4 Sep 2023 15:11:58 +0300 Subject: [PATCH] Revert "Deprecate class Id and NewId class factory (#5)" This reverts commit 2eff24312fc2e01aef10c4bd6d36f4654b7d9f23. --- ddd_framework/domain/model.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ddd_framework/domain/model.py b/ddd_framework/domain/model.py index dea3ec1..30ab049 100644 --- a/ddd_framework/domain/model.py +++ b/ddd_framework/domain/model.py @@ -1,6 +1,5 @@ from __future__ import annotations -import warnings from abc import ABC from datetime import datetime from typing import Any, Protocol, TypeVar @@ -45,8 +44,6 @@ def from_raw_id(cls, raw_id: str | int) -> Id: def NewId(name: str, base: type[Id] = Id) -> type[Id]: """Create a new identifier's type.""" - warnings.warn('Id class will be removed in the next update', DeprecationWarning, stacklevel=2) - return make_class(name, attrs={}, bases=(base,)) @@ -58,8 +55,6 @@ def structure_id(value: Any, _klass: type[Id]) -> Id: cattrs.register_structure_hook(Id, structure_id) -EntityId = Any - # endregion @@ -69,11 +64,11 @@ def structure_id(value: Any, _klass: type[Id]) -> Id: class Entity: """Represent an entity.""" - id: EntityId | Id | None = field(default=None) + id: Id | None = field(default=None) def __hash__(self) -> int: # TODO: Fix "Item "None" of "Id | None" has no attribute "id"" - return hash(self.id.id) if isinstance(self.id, Id) else hash(self.id) + return hash(self.id.id) # type: ignore # endregion