Skip to content

Commit

Permalink
Revert "Deprecate class Id and NewId class factory (#5)"
Browse files Browse the repository at this point in the history
This reverts commit 2eff243.
  • Loading branch information
NikBelyaev authored Sep 4, 2023
1 parent 2eff243 commit 320e96e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions ddd_framework/domain/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import warnings
from abc import ABC
from datetime import datetime
from typing import Any, Protocol, TypeVar
Expand Down Expand Up @@ -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,))


Expand All @@ -58,8 +55,6 @@ def structure_id(value: Any, _klass: type[Id]) -> Id:

cattrs.register_structure_hook(Id, structure_id)

EntityId = Any


# endregion

Expand All @@ -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
Expand Down

0 comments on commit 320e96e

Please sign in to comment.