eventsourcing 9.4.0a7__py3-none-any.whl → 9.4.0b1__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.

@@ -1,16 +1,17 @@
1
1
  import psycopg
2
+ from psycopg.sql import SQL, Identifier
2
3
 
3
4
  from eventsourcing.persistence import PersistenceError
4
5
  from eventsourcing.postgres import PostgresDatastore
5
6
 
6
7
 
7
8
  def pg_close_all_connections(
8
- name="eventsourcing",
9
- host="127.0.0.1",
10
- port="5432",
11
- user="postgres",
12
- password="postgres", # noqa: S107
13
- ):
9
+ name: str = "eventsourcing",
10
+ host: str = "127.0.0.1",
11
+ port: str = "5432",
12
+ user: str = "postgres",
13
+ password: str = "postgres", # noqa: S107
14
+ ) -> None:
14
15
  try:
15
16
  # For local development... probably.
16
17
  pg_conn = psycopg.connect(
@@ -40,11 +41,13 @@ def pg_close_all_connections(
40
41
  """
41
42
  pg_conn_cursor = pg_conn.cursor()
42
43
  pg_conn_cursor.execute(close_all_connections)
43
- return close_all_connections, pg_conn_cursor
44
44
 
45
45
 
46
- def drop_postgres_table(datastore: PostgresDatastore, table_name):
47
- statement = f"DROP TABLE {table_name}"
46
+ def drop_postgres_table(datastore: PostgresDatastore, table_name: str) -> None:
47
+ statement = SQL("DROP TABLE {0}.{1}").format(
48
+ Identifier(datastore.schema), Identifier(table_name)
49
+ )
50
+ # print(f"Dropping table {datastore.schema}.{table_name}")
48
51
  try:
49
52
  with datastore.transaction(commit=True) as curs:
50
53
  curs.execute(statement, prepare=False)
eventsourcing/utils.py CHANGED
@@ -2,13 +2,14 @@ from __future__ import annotations
2
2
 
3
3
  import importlib
4
4
  import sys
5
- from collections.abc import Iterator, Mapping, Sequence
5
+ from collections.abc import Iterator, Mapping
6
6
  from functools import wraps
7
7
  from inspect import isfunction
8
8
  from random import random
9
9
  from threading import Lock
10
10
  from time import sleep
11
- from typing import TYPE_CHECKING, Any, Callable, TypeVar, no_type_check, overload
11
+ from types import ModuleType
12
+ from typing import TYPE_CHECKING, Any, Callable, TypeVar, Union, no_type_check, overload
12
13
 
13
14
  if TYPE_CHECKING:
14
15
  from types import FunctionType, WrapperDescriptorType
@@ -20,12 +21,14 @@ class TopicError(Exception):
20
21
  """
21
22
 
22
23
 
23
- _type_cache: dict[type, str] = {}
24
- _topic_cache: dict[str, Any] = {}
24
+ SupportsTopic = Union[type, Callable[..., Any], ModuleType]
25
+
26
+ _type_cache: dict[SupportsTopic, str] = {}
27
+ _topic_cache: dict[str, SupportsTopic] = {}
25
28
  _topic_cache_lock = Lock()
26
29
 
27
30
 
28
- def get_topic(cls: type) -> str:
31
+ def get_topic(obj: SupportsTopic, /) -> str:
29
32
  """
30
33
  Returns a "topic string" that locates the given class
31
34
  in its module. The string is formed by joining the
@@ -33,11 +36,11 @@ def get_topic(cls: type) -> str:
33
36
  colon character.
34
37
  """
35
38
  try:
36
- return _type_cache[cls]
39
+ return _type_cache[obj]
37
40
  except KeyError:
38
- topic = f"{cls.__module__}:{cls.__qualname__}"
39
- register_topic(topic, cls)
40
- _type_cache[cls] = topic
41
+ topic = f"{obj.__module__}:{obj.__qualname__}"
42
+ register_topic(topic, obj)
43
+ _type_cache[obj] = topic
41
44
  return topic
42
45
 
43
46
 
@@ -97,7 +100,7 @@ def resolve_topic(topic: str) -> Any:
97
100
  return obj
98
101
 
99
102
 
100
- def register_topic(topic: str, obj: Any) -> None:
103
+ def register_topic(topic: str, obj: SupportsTopic) -> None:
101
104
  """
102
105
  Registers a topic with an object, so the object will be
103
106
  returned whenever the topic is resolved.
@@ -126,7 +129,7 @@ def clear_topic_cache() -> None:
126
129
 
127
130
 
128
131
  def retry(
129
- exc: type[Exception] | Sequence[type[Exception]] = Exception,
132
+ exc: type[Exception] | tuple[type[Exception], ...] = Exception,
130
133
  max_attempts: int = 1,
131
134
  wait: float = 0,
132
135
  stall: float = 0,
@@ -215,7 +218,9 @@ def reversed_keys(d: dict[Any, Any]) -> Iterator[Any]:
215
218
  return reversed(d.keys())
216
219
 
217
220
 
218
- def get_method_name(method: FunctionType | WrapperDescriptorType) -> str:
221
+ def get_method_name(
222
+ method: Callable[..., Any] | FunctionType | WrapperDescriptorType,
223
+ ) -> str:
219
224
  if sys.version_info >= (3, 10): # pragma: no cover
220
225
  return method.__qualname__
221
226
  return method.__name__ # pragma: no cover
@@ -230,18 +235,23 @@ class Environment(dict[str, str]):
230
235
  super().__init__(env or {})
231
236
  self.name = name
232
237
 
238
+ @overload # type: ignore[override]
239
+ def get(self, __key: str) -> str | None: ... # pragma: no cover
240
+
233
241
  @overload
234
- def get(self, key: str) -> str | None: ... # pragma: no cover
242
+ def get(self, __key: str, __default: str) -> str: ... # pragma: no cover
235
243
 
236
244
  @overload
237
- def get(self, key: str, default: str | T) -> str | T: ... # pragma: no cover
245
+ def get(self, __key: str, __default: T) -> str | T: ... # pragma: no cover
238
246
 
239
- def get(self, key: str, default: str | T | None = None) -> str | T | None:
240
- for _key in self.create_keys(key):
247
+ def get( # pyright: ignore [reportIncompatibleMethodOverride]
248
+ self, __key: str, __default: str | T | None = None
249
+ ) -> str | T | None:
250
+ for _key in self.create_keys(__key):
241
251
  value = super().get(_key, None)
242
252
  if value is not None:
243
253
  return value
244
- return default
254
+ return __default
245
255
 
246
256
  def create_keys(self, key: str) -> list[str]:
247
257
  keys = []
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: eventsourcing
3
- Version: 9.4.0a7
3
+ Version: 9.4.0b1
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
7
7
  Author: John Bywater
8
8
  Author-email: john.bywater@appropriatesoftware.net
9
9
  Requires-Python: >=3.9, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*, !=3.8.*
10
- Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Development Status :: 4 - Beta
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: Intended Audience :: Education
13
13
  Classifier: Intended Audience :: Science/Research
@@ -0,0 +1,26 @@
1
+ eventsourcing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ eventsourcing/application.py,sha256=lVgKXCeGA36CsUW7qgkkABX0mCUBvUH-QGQFtOYwmUw,35796
3
+ eventsourcing/cipher.py,sha256=R6bvq7Zcsd7NvV1o8WghdBcnqu0IDkOxlfxUSk1txeQ,3320
4
+ eventsourcing/compressor.py,sha256=IdvrJUB9B2td871oifInv4lGXmHwYL9d69MbHHCr7uI,421
5
+ eventsourcing/cryptography.py,sha256=ZsQFyeyMZysADqKy38ECV71j6EMMSbo3VQO7oRnC1h0,2994
6
+ eventsourcing/dispatch.py,sha256=3eVnGCagnn_CENSnTKonMt2kZ1eoHm8abdK7YRVONbU,2736
7
+ eventsourcing/domain.py,sha256=WwDwo-IxYrC3fEXu_5E2x-Vk4s1Ye9IaZSQLcUGhQqw,59889
8
+ eventsourcing/interface.py,sha256=uCoV9ARAu229SGwp169yeSLbB8wDLKDwWcnQdvOXOQM,5141
9
+ eventsourcing/persistence.py,sha256=hCS1vCtS5X_LUtycuDpF6d6Os7zjQ3qTnGf7W39DWV4,46139
10
+ eventsourcing/popo.py,sha256=xBUnnPuQ_wdF0ErU9AApRPwlkB0CJePMbWCz6qn3U1M,9654
11
+ eventsourcing/postgres.py,sha256=hHYpzvZc7nANXE1uQZ3gA-XKk5X9rB6nJ_zouOkpidk,37537
12
+ eventsourcing/projection.py,sha256=niCF9L5LsdeA0kgbKC3sE7p65rOF5du-YpdibkAhNU0,8588
13
+ eventsourcing/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ eventsourcing/sqlite.py,sha256=UVgG0JCmYr7xN8HHnoiMPpZtZ3d5NTfB-iq0MlZGax4,22051
15
+ eventsourcing/system.py,sha256=tyqGaGUE6CUGPWUZf27_26-Zl3PLsm3vK017Wxn7IM0,47279
16
+ eventsourcing/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ eventsourcing/tests/application.py,sha256=DEncXtCsX0X6Udua9GbGpua0xTGshnDPIThFfzuiBog,18025
18
+ eventsourcing/tests/domain.py,sha256=LkvGFYFc6jJR0PYjO2hAGPw0TNW8vUzdTuR8K5xDEQ0,3385
19
+ eventsourcing/tests/persistence.py,sha256=DePUevT4uYNTcIzVZoO6uzyyrUI2sOK6CSioiJRcD6I,58518
20
+ eventsourcing/tests/postgres_utils.py,sha256=0ywklGp6cXZ5PmV8ANVkwSHsZZCl5zTmOk7iG-RmrCE,1548
21
+ eventsourcing/utils.py,sha256=1mG24CXb4oRaumB6NMaH3QqxtHEiWTiJEWzFDRBf6nc,8537
22
+ eventsourcing-9.4.0b1.dist-info/AUTHORS,sha256=8aHOM4UbNZcKlD-cHpFRcM6RWyCqtwtxRev6DeUgVRs,137
23
+ eventsourcing-9.4.0b1.dist-info/LICENSE,sha256=CQEQzcZO8AWXL5i3hIo4yVKrYjh2FBz6hCM7kpXWpw4,1512
24
+ eventsourcing-9.4.0b1.dist-info/METADATA,sha256=Q4NfLZMDdQ9EKyxbXmk3_exmsHcD2PfOcSh-ldO3R-8,9796
25
+ eventsourcing-9.4.0b1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
26
+ eventsourcing-9.4.0b1.dist-info/RECORD,,
@@ -1,26 +0,0 @@
1
- eventsourcing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- eventsourcing/application.py,sha256=p8pBAWZ4HfHvHVZ2-enPE_WLokFqJNo6OEa6qU9_Zos,35973
3
- eventsourcing/cipher.py,sha256=AjgOlOv9FF6xyXiFnHwcK6NX5IJ3nPHFL5GzIyWozyg,3265
4
- eventsourcing/compressor.py,sha256=IdvrJUB9B2td871oifInv4lGXmHwYL9d69MbHHCr7uI,421
5
- eventsourcing/cryptography.py,sha256=ZsQFyeyMZysADqKy38ECV71j6EMMSbo3VQO7oRnC1h0,2994
6
- eventsourcing/dispatch.py,sha256=yYSpT-jqc6l_wTdqEnfPJJfvsZN2Ta8g2anrVPWIcqQ,1412
7
- eventsourcing/domain.py,sha256=_yacmQJBimumKbS3T-KLhvziVI0BWbDM7G5Opyh-Mu0,59578
8
- eventsourcing/interface.py,sha256=kObA7ouzLD4YpJMjhfPVmRUcDzhbK0bbFKXy75EscHU,5138
9
- eventsourcing/persistence.py,sha256=5fyJ9H7rgQY1M1cO6rfNU9VI2_GLn4KjFLia7lqXLSM,46147
10
- eventsourcing/popo.py,sha256=wSnpFutz24czC34v-Pd_OjMvv3RCXRjT0pk7ibkClrY,9573
11
- eventsourcing/postgres.py,sha256=WM23kJSmKzYvbiEU6y_E5WIuOIDMQfgLi2yHqazbj3c,36325
12
- eventsourcing/projection.py,sha256=x4lnqJbbnqwt_UKQN69jYSZEJkbhgvZgf-QX4c_y0lE,6774
13
- eventsourcing/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- eventsourcing/sqlite.py,sha256=ZiQSxaRULQMpK6RuiVQ1jD8dSMW_I-urzfAW6oL2FEk,21970
15
- eventsourcing/system.py,sha256=geMw08uAEySRHaNeDwYZyzD55WcduK7WP_BTy964dEU,47063
16
- eventsourcing/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- eventsourcing/tests/application.py,sha256=vHF5xp5WAXdTItdY5NsHvtT2QCRGmSM-j-afwFJqKj0,17357
18
- eventsourcing/tests/domain.py,sha256=lHSlY6jIoSeqlcPSbrrozEPUJGvJ8bgPrznlmzTxn2w,3254
19
- eventsourcing/tests/persistence.py,sha256=XHoe4rk9VftCJ3Wfi30K1u3wnMLUyOjuYyI7ml9ecIQ,57096
20
- eventsourcing/tests/postgres_utils.py,sha256=xymcGYasUXeZTBenkHz-ykD8HtrFjVM1Z7-qRrH6OQk,1364
21
- eventsourcing/utils.py,sha256=1MXOacnjXauYaBhGmmGc1nOMXWcd9NnDC8uPeiop9l4,8184
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,,