haiway 0.5.0__py3-none-any.whl → 0.5.2__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.
- haiway/__init__.py +2 -0
- haiway/context/metrics.py +2 -2
- haiway/helpers/__init__.py +2 -1
- haiway/helpers/asynchrony.py +17 -0
- haiway/state/structure.py +8 -2
- {haiway-0.5.0.dist-info → haiway-0.5.2.dist-info}/METADATA +7 -7
- {haiway-0.5.0.dist-info → haiway-0.5.2.dist-info}/RECORD +10 -10
- {haiway-0.5.0.dist-info → haiway-0.5.2.dist-info}/WHEEL +1 -1
- {haiway-0.5.0.dist-info → haiway-0.5.2.dist-info}/LICENSE +0 -0
- {haiway-0.5.0.dist-info → haiway-0.5.2.dist-info}/top_level.txt +0 -0
haiway/__init__.py
CHANGED
haiway/context/metrics.py
CHANGED
@@ -48,14 +48,14 @@ class ScopeMetrics:
|
|
48
48
|
self._logger: Logger = logger or getLogger(name=scope)
|
49
49
|
self._parent: Self | None = parent if parent else None
|
50
50
|
self._metrics: dict[type[State], State] = {}
|
51
|
-
self._nested:
|
51
|
+
self._nested: list[ScopeMetrics] = []
|
52
52
|
self._timestamp: float = monotonic()
|
53
53
|
self._finished: bool = False
|
54
54
|
self._loop: AbstractEventLoop = get_event_loop()
|
55
55
|
self._completed: Future[float] = self._loop.create_future()
|
56
56
|
|
57
57
|
if parent := parent:
|
58
|
-
parent._nested.
|
58
|
+
parent._nested.append(self)
|
59
59
|
|
60
60
|
freeze(self)
|
61
61
|
|
haiway/helpers/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from haiway.helpers.asynchrony import asynchronous
|
1
|
+
from haiway.helpers.asynchrony import asynchronous, wrap_async
|
2
2
|
from haiway.helpers.caching import cache
|
3
3
|
from haiway.helpers.retries import retry
|
4
4
|
from haiway.helpers.throttling import throttle
|
@@ -14,4 +14,5 @@ __all__ = [
|
|
14
14
|
"throttle",
|
15
15
|
"timeout",
|
16
16
|
"traced",
|
17
|
+
"wrap_async",
|
17
18
|
]
|
haiway/helpers/asynchrony.py
CHANGED
@@ -9,9 +9,26 @@ from haiway.types.missing import MISSING, Missing
|
|
9
9
|
|
10
10
|
__all__ = [
|
11
11
|
"asynchronous",
|
12
|
+
"wrap_async",
|
12
13
|
]
|
13
14
|
|
14
15
|
|
16
|
+
def wrap_async[**Args, Result](
|
17
|
+
function: Callable[Args, Coroutine[None, None, Result]] | Callable[Args, Result],
|
18
|
+
/,
|
19
|
+
) -> Callable[Args, Coroutine[None, None, Result]]:
|
20
|
+
if iscoroutinefunction(function):
|
21
|
+
return function
|
22
|
+
|
23
|
+
else:
|
24
|
+
|
25
|
+
async def async_function(*args: Args.args, **kwargs: Args.kwargs) -> Result:
|
26
|
+
return cast(Callable[Args, Result], function)(*args, **kwargs)
|
27
|
+
|
28
|
+
_mimic_async(function, within=async_function)
|
29
|
+
return async_function
|
30
|
+
|
31
|
+
|
15
32
|
@overload
|
16
33
|
def asynchronous[**Args, Result]() -> (
|
17
34
|
Callable[
|
haiway/state/structure.py
CHANGED
@@ -16,7 +16,7 @@ from weakref import WeakValueDictionary
|
|
16
16
|
|
17
17
|
from haiway.state.attributes import AttributeAnnotation, attribute_annotations
|
18
18
|
from haiway.state.validation import attribute_type_validator
|
19
|
-
from haiway.types
|
19
|
+
from haiway.types import MISSING, Missing, not_missing
|
20
20
|
|
21
21
|
__all__ = [
|
22
22
|
"State",
|
@@ -184,7 +184,13 @@ class State(metaclass=StateMeta):
|
|
184
184
|
return self.__replace__(**kwargs)
|
185
185
|
|
186
186
|
def as_dict(self) -> dict[str, Any]:
|
187
|
-
|
187
|
+
dict_result: dict[str, Any] = {}
|
188
|
+
for key in self.__ATTRIBUTES__.keys():
|
189
|
+
value: Any | Missing = getattr(self, key, MISSING)
|
190
|
+
if not_missing(value):
|
191
|
+
dict_result[key] = value
|
192
|
+
|
193
|
+
return dict_result
|
188
194
|
|
189
195
|
def __str__(self) -> str:
|
190
196
|
attributes: str = ", ".join([f"{key}: {value}" for key, value in vars(self).items()])
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: haiway
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.2
|
4
4
|
Summary: Framework for dependency injection and state management within structured concurrency model.
|
5
5
|
Maintainer-email: Kacper Kaliński <kacper.kalinski@miquido.com>
|
6
6
|
License: MIT License
|
@@ -36,12 +36,12 @@ Requires-Python: >=3.12
|
|
36
36
|
Description-Content-Type: text/markdown
|
37
37
|
License-File: LICENSE
|
38
38
|
Provides-Extra: dev
|
39
|
-
Requires-Dist: ruff
|
40
|
-
Requires-Dist: pyright
|
41
|
-
Requires-Dist: bandit
|
42
|
-
Requires-Dist: pytest
|
43
|
-
Requires-Dist: pytest-cov
|
44
|
-
Requires-Dist: pytest-asyncio
|
39
|
+
Requires-Dist: ruff~=0.5.0; extra == "dev"
|
40
|
+
Requires-Dist: pyright~=1.1; extra == "dev"
|
41
|
+
Requires-Dist: bandit~=1.7; extra == "dev"
|
42
|
+
Requires-Dist: pytest~=7.4; extra == "dev"
|
43
|
+
Requires-Dist: pytest-cov~=4.1; extra == "dev"
|
44
|
+
Requires-Dist: pytest-asyncio~=0.23.0; extra == "dev"
|
45
45
|
|
46
46
|
# 🚗 haiway 🚕 🚚 🚙
|
47
47
|
|
@@ -1,14 +1,14 @@
|
|
1
|
-
haiway/__init__.py,sha256=
|
1
|
+
haiway/__init__.py,sha256=ll2vI5w5LYylT0jdTE8_clfQJ2rpL4GKh8tR3Lr80j0,1301
|
2
2
|
haiway/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
haiway/context/__init__.py,sha256=21Y3zvRo1bHASZD6B_FNkU28k1-g88RdmUyqxvYXJxg,336
|
4
4
|
haiway/context/access.py,sha256=zPQcQBp5XMlNuszbxhtzi-5mNpDLpZ6PT-gVFDBH0dA,14115
|
5
5
|
haiway/context/disposables.py,sha256=DZjnMp-wMfF-em2Wjhbm1MvXubNpuzFBT70BQNIxC7M,2019
|
6
|
-
haiway/context/metrics.py,sha256=
|
6
|
+
haiway/context/metrics.py,sha256=0QRWXzi-LHO-jRmWmFP-vNBwR4TdjtcxCUurS2PSSVs,10756
|
7
7
|
haiway/context/state.py,sha256=GxGwPQTK8FdSprBd83lQbA9veubp0o93_1Yk3gb7HMc,3000
|
8
8
|
haiway/context/tasks.py,sha256=xXtXIUwXOra0EePTdkcEbMOmpWwFcO3hCRfR_IfvAHk,1978
|
9
9
|
haiway/context/types.py,sha256=VvJA7wAPZ3ISpgyThVguioYUXqhHf0XkPfRd0M1ERiQ,142
|
10
|
-
haiway/helpers/__init__.py,sha256=
|
11
|
-
haiway/helpers/asynchrony.py,sha256=
|
10
|
+
haiway/helpers/__init__.py,sha256=ZKa1_xreEVRcYrPTuPn5MRe-WrVFZ_FojswEtMqD5Qw,473
|
11
|
+
haiway/helpers/asynchrony.py,sha256=rh_Hwo0MQHfKnw5dLUCFTAm3Fk3SVS8Or8cTcQFdPA8,6042
|
12
12
|
haiway/helpers/caching.py,sha256=Ok_WE5Whe7XqnIuLZo4rNNBFeWap-aUWX799s4b1JAQ,9536
|
13
13
|
haiway/helpers/retries.py,sha256=gIkyUlqJLDYaxIZd3qzeqGFY9y5Gp8dgZLlZ6hs8hoc,7538
|
14
14
|
haiway/helpers/throttling.py,sha256=zo0OwFq64si5KUwhd58cFHLmGAmYwRbFRJMbv9suhPs,3844
|
@@ -16,7 +16,7 @@ haiway/helpers/timeouted.py,sha256=1xU09hQnFdj6p48BwZl5xUvtIr3zC0ZUXehkdrduCjs,3
|
|
16
16
|
haiway/helpers/tracing.py,sha256=yiK8MdDyX_fmpK9Zu5-IiZae5E8ReKQtRBBenXIPVqQ,3326
|
17
17
|
haiway/state/__init__.py,sha256=dh7l_ZImy0uHHDGD-fzMhQFmz_ej8WU8WEE2OmIoyVM,204
|
18
18
|
haiway/state/attributes.py,sha256=kkIYNlvWCM1NkgiCbE6gZDwgBVOk_TkmqWv67MmU0to,13399
|
19
|
-
haiway/state/structure.py,sha256=
|
19
|
+
haiway/state/structure.py,sha256=l8iYMCLEg5v1JVMwZ4R-YAXoQQZWkbWZyN6LcnzKqPQ,7237
|
20
20
|
haiway/state/validation.py,sha256=Z6kp_KjTnnP9eVWsLmzKkEQLZkhFCOSphjdbr6VxLFQ,3628
|
21
21
|
haiway/types/__init__.py,sha256=cAJQzDgFi8AKRqpzY3HWrutaPR69tnJqeJK_mQVtYUk,252
|
22
22
|
haiway/types/frozen.py,sha256=CZhFCXnWAKEhuWSfILxA8smfdpMd5Ku694ycfLh98R8,76
|
@@ -29,8 +29,8 @@ haiway/utils/logs.py,sha256=oDsc1ZdqKDjlTlctLbDcp9iX98Acr-1tdw-Pyg3DElo,1577
|
|
29
29
|
haiway/utils/mimic.py,sha256=BkVjTVP2TxxC8GChPGyDV6UXVwJmiRiSWeOYZNZFHxs,1828
|
30
30
|
haiway/utils/noop.py,sha256=qgbZlOKWY6_23Zs43OLukK2HagIQKRyR04zrFVm5rWI,344
|
31
31
|
haiway/utils/queue.py,sha256=oQ3GXCJ-PGNtMEr6EPdgqAvYZoj8lAa7Z2drBKBEoBM,2345
|
32
|
-
haiway-0.5.
|
33
|
-
haiway-0.5.
|
34
|
-
haiway-0.5.
|
35
|
-
haiway-0.5.
|
36
|
-
haiway-0.5.
|
32
|
+
haiway-0.5.2.dist-info/LICENSE,sha256=GehQEW_I1pkmxkkj3NEa7rCTQKYBn7vTPabpDYJlRuo,1063
|
33
|
+
haiway-0.5.2.dist-info/METADATA,sha256=5aQOjejITyf4CZ81axHemrQfhTu-WVHgwStsXt8Ol1k,3860
|
34
|
+
haiway-0.5.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
35
|
+
haiway-0.5.2.dist-info/top_level.txt,sha256=_LdXVLzUzgkvAGQnQJj5kQfoFhpPW6EF4Kj9NapniLg,7
|
36
|
+
haiway-0.5.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|