haiway 0.3.0__py3-none-any.whl → 0.3.1__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.
@@ -1,5 +1,5 @@
1
- from haiway.helpers.asynchronous import asynchronous
2
- from haiway.helpers.cached import cache
1
+ from haiway.helpers.asynchrony import asynchronous
2
+ from haiway.helpers.caching import cache
3
3
  from haiway.helpers.retries import retry
4
4
  from haiway.helpers.throttling import throttle
5
5
  from haiway.helpers.timeouted import timeout
@@ -3,9 +3,9 @@ from collections.abc import Callable, Coroutine
3
3
  from concurrent.futures import Executor
4
4
  from contextvars import Context, copy_context
5
5
  from functools import partial
6
- from typing import Any, Literal, cast, overload
6
+ from typing import Any, cast, overload
7
7
 
8
- from haiway.types.missing import MISSING, Missing, not_missing
8
+ from haiway.types.missing import MISSING, Missing
9
9
 
10
10
  __all__ = [
11
11
  "asynchronous",
@@ -25,7 +25,7 @@ def asynchronous[**Args, Result]() -> (
25
25
  def asynchronous[**Args, Result](
26
26
  *,
27
27
  loop: AbstractEventLoop | None = None,
28
- executor: Executor | Literal["default"],
28
+ executor: Executor,
29
29
  ) -> Callable[
30
30
  [Callable[Args, Result]],
31
31
  Callable[Args, Coroutine[None, None, Result]],
@@ -43,7 +43,7 @@ def asynchronous[**Args, Result](
43
43
  function: Callable[Args, Result] | None = None,
44
44
  /,
45
45
  loop: AbstractEventLoop | None = None,
46
- executor: Executor | Literal["default"] | Missing = MISSING,
46
+ executor: Executor | Missing = MISSING,
47
47
  ) -> (
48
48
  Callable[
49
49
  [Callable[Args, Result]],
@@ -63,10 +63,9 @@ def asynchronous[**Args, Result](
63
63
  loop: AbstractEventLoop | None
64
64
  loop used to call the function. When None was provided the loop currently running while \
65
65
  executing the function will be used. Default is None.
66
- executor: Executor | Literal["default"] | Missing
67
- executor used to run the function. Specifying "default" uses a default loop executor.
68
- When not provided (Missing) no executor will be used \
69
- (function will by just wrapped as an async function without any executor)
66
+ executor: Executor | Missing
67
+ executor used to run the function. When not provided (Missing) default loop executor\
68
+ will be used.
70
69
 
71
70
  Returns
72
71
  -------
@@ -79,26 +78,11 @@ def asynchronous[**Args, Result](
79
78
  ) -> Callable[Args, Coroutine[None, None, Result]]:
80
79
  assert not iscoroutinefunction(wrapped), "Cannot wrap async function in executor" # nosec: B101
81
80
 
82
- if not_missing(executor):
83
- return _ExecutorWrapper(
84
- wrapped,
85
- loop=loop,
86
- executor=cast(Executor | None, None if executor == "default" else executor),
87
- )
88
-
89
- else:
90
-
91
- async def wrapper(
92
- *args: Args.args,
93
- **kwargs: Args.kwargs,
94
- ) -> Result:
95
- return wrapped(
96
- *args,
97
- **kwargs,
98
- )
99
-
100
- _mimic_async(wrapped, within=wrapper)
101
- return wrapper
81
+ return _ExecutorWrapper(
82
+ wrapped,
83
+ loop=loop,
84
+ executor=cast(Executor | None, None if executor is MISSING else executor),
85
+ )
102
86
 
103
87
  if function := function:
104
88
  return wrap(wrapped=function)
haiway/types/missing.py CHANGED
@@ -46,20 +46,20 @@ class Missing(metaclass=MissingType):
46
46
  self,
47
47
  name: str,
48
48
  ) -> Any:
49
- raise RuntimeError("Missing has no attributes")
49
+ raise AttributeError("Missing has no attributes")
50
50
 
51
51
  def __setattr__(
52
52
  self,
53
53
  __name: str,
54
54
  __value: Any,
55
55
  ) -> None:
56
- raise RuntimeError("Missing can't be modified")
56
+ raise AttributeError("Missing can't be modified")
57
57
 
58
58
  def __delattr__(
59
59
  self,
60
60
  __name: str,
61
61
  ) -> None:
62
- raise RuntimeError("Missing can't be modified")
62
+ raise AttributeError("Missing can't be modified")
63
63
 
64
64
 
65
65
  MISSING: Final[Missing] = Missing()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: haiway
3
- Version: 0.3.0
3
+ Version: 0.3.1
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
@@ -7,9 +7,9 @@ haiway/context/metrics.py,sha256=upkqUp47NymDJE8UQznr99AgaE9yw6i28l_cdCE1IeM,861
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=G8cbw11yb7VxGkAqjVmXPcYKR0eGe-UHa0LUtgHA3Jc,318
11
- haiway/helpers/asynchronous.py,sha256=FYcV_ERrGy7f47y18oKeUk7fcbk-i_SOuPQ7lHhX5iI,6119
12
- haiway/helpers/cached.py,sha256=Ok_WE5Whe7XqnIuLZo4rNNBFeWap-aUWX799s4b1JAQ,9536
10
+ haiway/helpers/__init__.py,sha256=mXTpvTqRqmKiCE2ZHKDgSo8i9gRbEWGw-Qj2a_M0sD4,317
11
+ haiway/helpers/asynchrony.py,sha256=FPqmFFRDtAn8migwYHFKViKHypNHZW3cJCrh9y03AwI,5526
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
15
15
  haiway/helpers/timeouted.py,sha256=1xU09hQnFdj6p48BwZl5xUvtIr3zC0ZUXehkdrduCjs,3074
@@ -19,7 +19,7 @@ haiway/state/structure.py,sha256=G-Ln72hoQtE0FmKHeZdNmXf_FA3f5-e5AGbmJ2yMNb4,700
19
19
  haiway/state/validation.py,sha256=V4Q94Ik4p9t7f-7EIwK3Q9Zki8VkLOjPIGWGwLRVCoc,2873
20
20
  haiway/types/__init__.py,sha256=cAJQzDgFi8AKRqpzY3HWrutaPR69tnJqeJK_mQVtYUk,252
21
21
  haiway/types/frozen.py,sha256=CZhFCXnWAKEhuWSfILxA8smfdpMd5Ku694ycfLh98R8,76
22
- haiway/types/missing.py,sha256=3t2bcZuw5fAKiycP-0Aly2TDUWtM3xyHy3KDCT91TLs,1660
22
+ haiway/types/missing.py,sha256=xR5Hzk134_htlfac4OBWg6Xkobu71hF9CSVA3qeHBYY,1666
23
23
  haiway/utils/__init__.py,sha256=UA9h8YDvYI5rYujvsIS9t5Q-SWYImmk30uhR_42flqs,608
24
24
  haiway/utils/always.py,sha256=2abp8Lm9rQkrfS3rm1Iqhb-IcWyVfH1BULab3KMxgOw,1234
25
25
  haiway/utils/env.py,sha256=lKPOBZWyRD_gQariDGBjVLYTm0740nytPCSQpK2oRyE,3136
@@ -28,8 +28,8 @@ haiway/utils/logs.py,sha256=oDsc1ZdqKDjlTlctLbDcp9iX98Acr-1tdw-Pyg3DElo,1577
28
28
  haiway/utils/mimic.py,sha256=BkVjTVP2TxxC8GChPGyDV6UXVwJmiRiSWeOYZNZFHxs,1828
29
29
  haiway/utils/noop.py,sha256=qgbZlOKWY6_23Zs43OLukK2HagIQKRyR04zrFVm5rWI,344
30
30
  haiway/utils/queue.py,sha256=WGW8kSusIwRYHsYRIKD2CaqhhC1pUtVgtNHFDXDtYrw,2443
31
- haiway-0.3.0.dist-info/LICENSE,sha256=GehQEW_I1pkmxkkj3NEa7rCTQKYBn7vTPabpDYJlRuo,1063
32
- haiway-0.3.0.dist-info/METADATA,sha256=rABSQCD4Sboe2cC-p3hruWyxM0DrxggLozH0Ma-MIYM,3872
33
- haiway-0.3.0.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
34
- haiway-0.3.0.dist-info/top_level.txt,sha256=_LdXVLzUzgkvAGQnQJj5kQfoFhpPW6EF4Kj9NapniLg,7
35
- haiway-0.3.0.dist-info/RECORD,,
31
+ haiway-0.3.1.dist-info/LICENSE,sha256=GehQEW_I1pkmxkkj3NEa7rCTQKYBn7vTPabpDYJlRuo,1063
32
+ haiway-0.3.1.dist-info/METADATA,sha256=ElVgToccvxi6C6UcuG3iqGKPAyJUcacRclp6YJ9A4hw,3872
33
+ haiway-0.3.1.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
34
+ haiway-0.3.1.dist-info/top_level.txt,sha256=_LdXVLzUzgkvAGQnQJj5kQfoFhpPW6EF4Kj9NapniLg,7
35
+ haiway-0.3.1.dist-info/RECORD,,
File without changes
File without changes