haiway 0.10.10__py3-none-any.whl → 0.10.13__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/helpers/tracing.py CHANGED
@@ -74,6 +74,7 @@ def traced[**Args, Result](
74
74
  label=function.__name__,
75
75
  ),
76
76
  )
77
+
77
78
  else:
78
79
  return _traced_sync(
79
80
  function,
@@ -101,7 +102,7 @@ def _traced_sync[**Args, Result](
101
102
  return result
102
103
 
103
104
  except BaseException as exc:
104
- ctx.record(ResultTrace.of(exc))
105
+ ctx.record(ResultTrace.of(f"{type(exc)}: {exc}"))
105
106
  raise exc
106
107
 
107
108
  return mimic_function(
@@ -127,7 +128,7 @@ def _traced_async[**Args, Result](
127
128
  return result
128
129
 
129
130
  except BaseException as exc:
130
- ctx.record(ResultTrace.of(exc))
131
+ ctx.record(ResultTrace.of(f"{type(exc)}: {exc}"))
131
132
  raise exc
132
133
 
133
134
  return mimic_function(
@@ -66,6 +66,9 @@ class AttributeAnnotation:
66
66
  return self
67
67
 
68
68
  def __str__(self) -> str:
69
+ if alias := self.extra.get("TYPE_ALIAS"):
70
+ return alias
71
+
69
72
  origin_str: str = getattr(self.origin, "__name__", str(self.origin))
70
73
  arguments_str: str
71
74
  if self.arguments:
@@ -337,7 +340,10 @@ def _resolve_type_alias(
337
340
 
338
341
  resolved_attribute.origin = resolved.origin
339
342
  resolved_attribute.arguments = resolved.arguments
340
- resolved_attribute.extra = resolved.extra
343
+ resolved_attribute.extra = {
344
+ **resolved.extra,
345
+ "TYPE_ALIAS": annotation.__name__,
346
+ }
341
347
  resolved_attribute.required = resolved.required
342
348
 
343
349
  return resolved_attribute
@@ -1,4 +1,5 @@
1
1
  from collections.abc import Mapping, Sequence, Set
2
+ from typing import overload
2
3
 
3
4
  __all__ = [
4
5
  "as_dict",
@@ -8,24 +9,43 @@ __all__ = [
8
9
  ]
9
10
 
10
11
 
12
+ @overload
11
13
  def as_list[T](
12
14
  collection: Sequence[T],
13
15
  /,
14
- ) -> list[T]:
16
+ ) -> list[T]: ...
17
+
18
+
19
+ @overload
20
+ def as_list[T](
21
+ collection: Sequence[T] | None,
22
+ /,
23
+ ) -> list[T] | None: ...
24
+
25
+
26
+ def as_list[T](
27
+ collection: Sequence[T] | None,
28
+ /,
29
+ ) -> list[T] | None:
15
30
  """
16
31
  Converts any given Sequence into a list.
17
32
 
18
33
  Parameters
19
34
  ----------
20
- collection : Sequence[T]
35
+ collection : Sequence[T] | None
21
36
  The input collection to be converted.
22
37
 
23
38
  Returns
24
39
  -------
25
- list[T]
26
- A new list containing all elements of the input collection,
27
- or the original list if it was already one.
40
+ list[T] | None
41
+ A new list containing all elements of the input collection,\
42
+ or the original list if it was already one.
43
+ None if no value was provided.
28
44
  """
45
+
46
+ if collection is None:
47
+ return None
48
+
29
49
  if isinstance(collection, list):
30
50
  return collection
31
51
 
@@ -33,24 +53,43 @@ def as_list[T](
33
53
  return list(collection)
34
54
 
35
55
 
56
+ @overload
36
57
  def as_tuple[T](
37
58
  collection: Sequence[T],
38
59
  /,
39
- ) -> tuple[T, ...]:
60
+ ) -> tuple[T, ...]: ...
61
+
62
+
63
+ @overload
64
+ def as_tuple[T](
65
+ collection: Sequence[T] | None,
66
+ /,
67
+ ) -> tuple[T, ...] | None: ...
68
+
69
+
70
+ def as_tuple[T](
71
+ collection: Sequence[T] | None,
72
+ /,
73
+ ) -> tuple[T, ...] | None:
40
74
  """
41
75
  Converts any given Sequence into a tuple.
42
76
 
43
77
  Parameters
44
78
  ----------
45
- collection : Sequence[T]
79
+ collection : Sequence[T] | None
46
80
  The input collection to be converted.
47
81
 
48
82
  Returns
49
83
  -------
50
- tuple[T]
51
- A new tuple containing all elements of the input collection,
52
- or the original tuple if it was already one.
84
+ tuple[T] | None
85
+ A new tuple containing all elements of the input collection,\
86
+ or the original tuple if it was already one.
87
+ None if no value was provided.
53
88
  """
89
+
90
+ if collection is None:
91
+ return None
92
+
54
93
  if isinstance(collection, tuple):
55
94
  return collection
56
95
 
@@ -58,10 +97,24 @@ def as_tuple[T](
58
97
  return tuple(collection)
59
98
 
60
99
 
100
+ @overload
61
101
  def as_set[T](
62
102
  collection: Set[T],
63
103
  /,
64
- ) -> set[T]:
104
+ ) -> set[T]: ...
105
+
106
+
107
+ @overload
108
+ def as_set[T](
109
+ collection: Set[T] | None,
110
+ /,
111
+ ) -> set[T] | None: ...
112
+
113
+
114
+ def as_set[T](
115
+ collection: Set[T] | None,
116
+ /,
117
+ ) -> set[T] | None:
65
118
  """
66
119
  Converts any given Set into a set.
67
120
 
@@ -73,9 +126,14 @@ def as_set[T](
73
126
  Returns
74
127
  -------
75
128
  set[T]
76
- A new set containing all elements of the input collection,
77
- or the original set if it was already one.
129
+ A new set containing all elements of the input collection,\
130
+ or the original set if it was already one.
131
+ None if no value was provided.
78
132
  """
133
+
134
+ if collection is None:
135
+ return None
136
+
79
137
  if isinstance(collection, set):
80
138
  return collection
81
139
 
@@ -83,10 +141,24 @@ def as_set[T](
83
141
  return set(collection)
84
142
 
85
143
 
144
+ @overload
86
145
  def as_dict[K, V](
87
146
  collection: Mapping[K, V],
88
147
  /,
89
- ) -> dict[K, V]:
148
+ ) -> dict[K, V]: ...
149
+
150
+
151
+ @overload
152
+ def as_dict[K, V](
153
+ collection: Mapping[K, V] | None,
154
+ /,
155
+ ) -> dict[K, V] | None: ...
156
+
157
+
158
+ def as_dict[K, V](
159
+ collection: Mapping[K, V] | None,
160
+ /,
161
+ ) -> dict[K, V] | None:
90
162
  """
91
163
  Converts any given Mapping into a dict.
92
164
 
@@ -98,9 +170,14 @@ def as_dict[K, V](
98
170
  Returns
99
171
  -------
100
172
  dict[K, V]
101
- A new dict containing all elements of the input collection,
102
- or the original dict if it was already one.
173
+ A new dict containing all elements of the input collection,\
174
+ or the original dict if it was already one.
175
+ None if no value was provided.
103
176
  """
177
+
178
+ if collection is None:
179
+ return None
180
+
104
181
  if isinstance(collection, dict):
105
182
  return collection
106
183
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haiway
3
- Version: 0.10.10
3
+ Version: 0.10.13
4
4
  Summary: Framework for dependency injection and state management within structured concurrency model.
5
5
  Project-URL: Homepage, https://miquido.com
6
6
  Project-URL: Repository, https://github.com/miquido/haiway.git
@@ -16,9 +16,9 @@ haiway/helpers/metrics.py,sha256=0oFBiO-hAzihyC5jvXevNrYOoTcUGc2yGhE1A_866Mc,133
16
16
  haiway/helpers/retries.py,sha256=gIkyUlqJLDYaxIZd3qzeqGFY9y5Gp8dgZLlZ6hs8hoc,7538
17
17
  haiway/helpers/throttling.py,sha256=zo0OwFq64si5KUwhd58cFHLmGAmYwRbFRJMbv9suhPs,3844
18
18
  haiway/helpers/timeouted.py,sha256=1xU09hQnFdj6p48BwZl5xUvtIr3zC0ZUXehkdrduCjs,3074
19
- haiway/helpers/tracing.py,sha256=eQpkIoGSB51jRF8RcLaihvHX3VzJIRdyRxTx3I14Pzg,3346
19
+ haiway/helpers/tracing.py,sha256=VDOAhdVELaYs92HxHreEo_ZV8b7e6ZQs10lTNn8xOtQ,3383
20
20
  haiway/state/__init__.py,sha256=emTuwGFn7HyjyTJ_ass69J5jQIA7_WHO4teZz_dR05Y,355
21
- haiway/state/attributes.py,sha256=0gJbgOKiH79RNM9IW66NNWSWM29037yGTTpoln6vPvU,22984
21
+ haiway/state/attributes.py,sha256=plCcYGE5LVU1Nvo0GHkhThqFG96uLR3tFsisQyK1jK0,23122
22
22
  haiway/state/path.py,sha256=4vh-fYQv8_xRWjS0ErMQslKDWRI6-KVECAr8JhYk0UY,17503
23
23
  haiway/state/requirement.py,sha256=3iQqzp5Q7w6y5uClamJGH7S5Hib9pciuTAV27PP5lS8,6161
24
24
  haiway/state/structure.py,sha256=bSIj0S_HG-F1Z5GxSlY6VpGtrtiwG82-AIL_PL1lRLo,12465
@@ -29,14 +29,14 @@ haiway/types/frozen.py,sha256=CZhFCXnWAKEhuWSfILxA8smfdpMd5Ku694ycfLh98R8,76
29
29
  haiway/types/missing.py,sha256=rDnyA2wxPkTbJl0L-zbo0owp7IJ04xkCIp6xD6wh8NI,1712
30
30
  haiway/utils/__init__.py,sha256=O7qmAmUktX-X_5D1L5FJMeCFEiOVrrnyYSyiycm4nyg,739
31
31
  haiway/utils/always.py,sha256=2abp8Lm9rQkrfS3rm1Iqhb-IcWyVfH1BULab3KMxgOw,1234
32
- haiway/utils/collections.py,sha256=_MwB4o8sCZeAjrwry8Pu9JvGlt8m7O7MqWSFFmPjJ6k,2120
32
+ haiway/utils/collections.py,sha256=pKHZhXqTMcOth7gV6mXcC5WcSyBl70MmVIELbDSmMoA,3320
33
33
  haiway/utils/env.py,sha256=vlW21LEp8uOVNnUXpBfPtj3zKi9Kkjoemb_H5hQpYPQ,4433
34
34
  haiway/utils/freezing.py,sha256=K34ZIMzbkpgkHKH-KF73plEbXExsajNRkRTYp9nJEf4,620
35
35
  haiway/utils/logs.py,sha256=oDsc1ZdqKDjlTlctLbDcp9iX98Acr-1tdw-Pyg3DElo,1577
36
36
  haiway/utils/mimic.py,sha256=BkVjTVP2TxxC8GChPGyDV6UXVwJmiRiSWeOYZNZFHxs,1828
37
37
  haiway/utils/noop.py,sha256=qgbZlOKWY6_23Zs43OLukK2HagIQKRyR04zrFVm5rWI,344
38
38
  haiway/utils/queue.py,sha256=oQ3GXCJ-PGNtMEr6EPdgqAvYZoj8lAa7Z2drBKBEoBM,2345
39
- haiway-0.10.10.dist-info/METADATA,sha256=PhcebR048J2VPSVrFIQOnQSEIvQpwolFKMmRuOGTWAg,3858
40
- haiway-0.10.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
41
- haiway-0.10.10.dist-info/licenses/LICENSE,sha256=GehQEW_I1pkmxkkj3NEa7rCTQKYBn7vTPabpDYJlRuo,1063
42
- haiway-0.10.10.dist-info/RECORD,,
39
+ haiway-0.10.13.dist-info/METADATA,sha256=QyxvFJSNQ9BQON9joaMqHB8DRsoexEfcAwQXmESkljU,3858
40
+ haiway-0.10.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
41
+ haiway-0.10.13.dist-info/licenses/LICENSE,sha256=GehQEW_I1pkmxkkj3NEa7rCTQKYBn7vTPabpDYJlRuo,1063
42
+ haiway-0.10.13.dist-info/RECORD,,