eventsourcing 9.4.0a6__py3-none-any.whl → 9.4.0a7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of eventsourcing might be problematic. Click here for more details.

@@ -19,8 +19,6 @@ from typing import (
19
19
  )
20
20
  from warnings import warn
21
21
 
22
- from typing_extensions import deprecated
23
-
24
22
  from eventsourcing.domain import (
25
23
  Aggregate,
26
24
  CanMutateProtocol,
@@ -905,14 +903,7 @@ class Application:
905
903
  TApplication = TypeVar("TApplication", bound=Application)
906
904
 
907
905
 
908
- @deprecated(
909
- "AggregateNotFound is deprecated, use AggregateNotFoundError instead", category=None
910
- )
911
- class AggregateNotFound(EventSourcingError): # noqa: N818
912
- pass
913
-
914
-
915
- class AggregateNotFoundError(AggregateNotFound):
906
+ class AggregateNotFoundError(EventSourcingError):
916
907
  """
917
908
  Raised when an :class:`~eventsourcing.domain.Aggregate`
918
909
  object is not found in a :class:`Repository`.
eventsourcing/domain.py CHANGED
@@ -1,8 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import dataclasses
4
+ import importlib
3
5
  import inspect
4
6
  import os
5
- from dataclasses import dataclass
6
7
  from datetime import datetime, tzinfo
7
8
  from functools import cache
8
9
  from types import FunctionType, WrapperDescriptorType
@@ -336,7 +337,7 @@ class MetaDomainEvent(type):
336
337
  event_cls = cast(
337
338
  type[TDomainEvent], super().__new__(cls, name, bases, cls_dict)
338
339
  )
339
- event_cls = dataclass(frozen=True)(event_cls)
340
+ event_cls = dataclasses.dataclass(frozen=True)(event_cls)
340
341
  event_cls.__signature__ = inspect.signature(event_cls.__init__) # type: ignore
341
342
  return event_cls
342
343
 
@@ -886,6 +887,34 @@ _annotations_mention_id: set[MetaAggregate[Aggregate]] = set()
886
887
  _init_mentions_id: set[MetaAggregate[Aggregate]] = set()
887
888
 
888
889
 
890
+ def _ensure_idempotent_dataclass(module_name: str) -> None:
891
+ module = importlib.import_module(module_name)
892
+ if (
893
+ "dataclass" in module.__dict__
894
+ and module.__dict__["dataclass"] == dataclasses.dataclass
895
+ and "__original_dataclass_func__" not in module.__dict__
896
+ ):
897
+ module.__dict__["__original_dataclass_func__"] = module.__dict__["dataclass"]
898
+ module.__dict__["dataclass"] = _idempotent_dataclass
899
+
900
+
901
+ def _idempotent_dataclass(cls: type[object] | None = None, /, **kwargs: Any) -> Any:
902
+
903
+ def idempotent_wrap(cls: type[object]) -> type[object]:
904
+ # Avoid processing dataclass twice.
905
+ if "__dataclass_fields__" in cls.__dict__:
906
+ return cls
907
+ return dataclasses.dataclass(**kwargs)(cls)
908
+
909
+ # See if we're being called as @dataclass or @dataclass().
910
+ if cls is None:
911
+ # We're called with parens.
912
+ return idempotent_wrap
913
+
914
+ # We're called as @dataclass without parens.
915
+ return idempotent_wrap(cls)
916
+
917
+
889
918
  class MetaAggregate(type, Generic[TAggregate]):
890
919
  """
891
920
  Metaclass for aggregate classes.
@@ -924,6 +953,12 @@ class MetaAggregate(type, Generic[TAggregate]):
924
953
  """
925
954
  Configures aggregate class definition.
926
955
  """
956
+
957
+ # Avoid processing dataclass twice. This avoids dataclasses.Field(init=False)
958
+ # attributes being reduced to annotation only and then appearing in __init__
959
+ # method signature when class is reprocessed, and other similar problems.
960
+ _ensure_idempotent_dataclass(module_name=args[2]["__module__"])
961
+
927
962
  try:
928
963
  class_annotations = args[2]["__annotations__"]
929
964
  except KeyError:
@@ -937,8 +972,8 @@ class MetaAggregate(type, Generic[TAggregate]):
937
972
  else:
938
973
  annotations_mention_id = True
939
974
  aggregate_cls = type.__new__(cls, *args)
940
- if class_annotations:
941
- aggregate_cls = dataclass(eq=False, repr=False)(aggregate_cls)
975
+ if class_annotations or any(dataclasses.is_dataclass(base) for base in args[1]):
976
+ aggregate_cls = dataclasses.dataclass(eq=False, repr=False)(aggregate_cls)
942
977
  if annotations_mention_id:
943
978
  _annotations_mention_id.add(aggregate_cls)
944
979
  return aggregate_cls
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: eventsourcing
3
- Version: 9.4.0a6
3
+ Version: 9.4.0a7
4
4
  Summary: Event sourcing in Python
5
5
  License: BSD 3-Clause
6
6
  Keywords: event sourcing,event store,domain driven design,domain-driven design,ddd,cqrs,cqs
@@ -1,10 +1,10 @@
1
1
  eventsourcing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- eventsourcing/application.py,sha256=jnW_D1WpcH_S9tOER36xzy3juYzm9D3f-nGTKAU8RpI,36188
2
+ eventsourcing/application.py,sha256=p8pBAWZ4HfHvHVZ2-enPE_WLokFqJNo6OEa6qU9_Zos,35973
3
3
  eventsourcing/cipher.py,sha256=AjgOlOv9FF6xyXiFnHwcK6NX5IJ3nPHFL5GzIyWozyg,3265
4
4
  eventsourcing/compressor.py,sha256=IdvrJUB9B2td871oifInv4lGXmHwYL9d69MbHHCr7uI,421
5
5
  eventsourcing/cryptography.py,sha256=ZsQFyeyMZysADqKy38ECV71j6EMMSbo3VQO7oRnC1h0,2994
6
6
  eventsourcing/dispatch.py,sha256=yYSpT-jqc6l_wTdqEnfPJJfvsZN2Ta8g2anrVPWIcqQ,1412
7
- eventsourcing/domain.py,sha256=3pg7OtnupNFEJxLH0cur1k6rSFspYX2Ic6wteuEjtxE,58170
7
+ eventsourcing/domain.py,sha256=_yacmQJBimumKbS3T-KLhvziVI0BWbDM7G5Opyh-Mu0,59578
8
8
  eventsourcing/interface.py,sha256=kObA7ouzLD4YpJMjhfPVmRUcDzhbK0bbFKXy75EscHU,5138
9
9
  eventsourcing/persistence.py,sha256=5fyJ9H7rgQY1M1cO6rfNU9VI2_GLn4KjFLia7lqXLSM,46147
10
10
  eventsourcing/popo.py,sha256=wSnpFutz24czC34v-Pd_OjMvv3RCXRjT0pk7ibkClrY,9573
@@ -19,8 +19,8 @@ eventsourcing/tests/domain.py,sha256=lHSlY6jIoSeqlcPSbrrozEPUJGvJ8bgPrznlmzTxn2w
19
19
  eventsourcing/tests/persistence.py,sha256=XHoe4rk9VftCJ3Wfi30K1u3wnMLUyOjuYyI7ml9ecIQ,57096
20
20
  eventsourcing/tests/postgres_utils.py,sha256=xymcGYasUXeZTBenkHz-ykD8HtrFjVM1Z7-qRrH6OQk,1364
21
21
  eventsourcing/utils.py,sha256=1MXOacnjXauYaBhGmmGc1nOMXWcd9NnDC8uPeiop9l4,8184
22
- eventsourcing-9.4.0a6.dist-info/AUTHORS,sha256=8aHOM4UbNZcKlD-cHpFRcM6RWyCqtwtxRev6DeUgVRs,137
23
- eventsourcing-9.4.0a6.dist-info/LICENSE,sha256=CQEQzcZO8AWXL5i3hIo4yVKrYjh2FBz6hCM7kpXWpw4,1512
24
- eventsourcing-9.4.0a6.dist-info/METADATA,sha256=DyLTvR4U5LLER3GR88LJkFHdSB6RlZ7MnsFE30OzAi0,9797
25
- eventsourcing-9.4.0a6.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
26
- eventsourcing-9.4.0a6.dist-info/RECORD,,
22
+ eventsourcing-9.4.0a7.dist-info/AUTHORS,sha256=8aHOM4UbNZcKlD-cHpFRcM6RWyCqtwtxRev6DeUgVRs,137
23
+ eventsourcing-9.4.0a7.dist-info/LICENSE,sha256=CQEQzcZO8AWXL5i3hIo4yVKrYjh2FBz6hCM7kpXWpw4,1512
24
+ eventsourcing-9.4.0a7.dist-info/METADATA,sha256=lDtJGwMp3HAxuQIFxfmAZfW7vhvBIPrUpZS3EykR9SQ,9797
25
+ eventsourcing-9.4.0a7.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
26
+ eventsourcing-9.4.0a7.dist-info/RECORD,,