haiway 0.15.1__py3-none-any.whl → 0.15.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 CHANGED
@@ -58,6 +58,7 @@ from haiway.utils import (
58
58
  mimic_function,
59
59
  noop,
60
60
  setup_logging,
61
+ without_missing,
61
62
  )
62
63
 
63
64
  __all__ = [
@@ -115,5 +116,6 @@ __all__ = [
115
116
  "timeout",
116
117
  "traced",
117
118
  "when_missing",
119
+ "without_missing",
118
120
  "wrap_async",
119
121
  ]
haiway/utils/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from haiway.utils.always import always, async_always
2
- from haiway.utils.collections import as_dict, as_list, as_set, as_tuple
2
+ from haiway.utils.collections import as_dict, as_list, as_set, as_tuple, without_missing
3
3
  from haiway.utils.env import (
4
4
  getenv_base64,
5
5
  getenv_bool,
@@ -35,4 +35,5 @@ __all__ = [
35
35
  "mimic_function",
36
36
  "noop",
37
37
  "setup_logging",
38
+ "without_missing",
38
39
  ]
@@ -1,11 +1,14 @@
1
1
  from collections.abc import Iterable, Mapping, Set
2
- from typing import overload
2
+ from typing import Any, cast, overload
3
+
4
+ from haiway.types.missing import MISSING
3
5
 
4
6
  __all__ = [
5
7
  "as_dict",
6
8
  "as_list",
7
9
  "as_set",
8
10
  "as_tuple",
11
+ "without_missing",
9
12
  ]
10
13
 
11
14
 
@@ -183,3 +186,42 @@ def as_dict[K, V](
183
186
 
184
187
  else:
185
188
  return dict(collection)
189
+
190
+
191
+ @overload
192
+ def without_missing[T: Mapping[str, Any]](
193
+ mapping: Mapping[str, Any],
194
+ /,
195
+ ) -> Mapping[str, Any]: ...
196
+
197
+
198
+ @overload
199
+ def without_missing[T: Mapping[str, Any]](
200
+ mapping: Mapping[str, Any],
201
+ /,
202
+ *,
203
+ typed: type[T],
204
+ ) -> T: ...
205
+
206
+
207
+ def without_missing[T: Mapping[str, Any]](
208
+ mapping: Mapping[str, Any],
209
+ /,
210
+ *,
211
+ typed: type[T] | None = None,
212
+ ) -> T | Mapping[str, Any]:
213
+ """
214
+ Strip items with missing values.
215
+
216
+ Parameters
217
+ ----------
218
+ mapping : Mapping[K, V]
219
+ The input mapping to be stripped.
220
+
221
+ Returns
222
+ -------
223
+ T | dict[str, Any]
224
+ A new mapping containing all items of the input mapping,\
225
+ except items with missing values.
226
+ """
227
+ return cast(T, {key: value for key, value in mapping.items() if value is not MISSING})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haiway
3
- Version: 0.15.1
3
+ Version: 0.15.2
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
@@ -1,4 +1,4 @@
1
- haiway/__init__.py,sha256=RhW9HOIAVQ3srQ-v23tPghJ20dWcn_uAyt8U8Hhn868,2081
1
+ haiway/__init__.py,sha256=XahuBwbI7ZFBBkcbs5882Go7QrzLtEq9XylQzuR1AJY,2125
2
2
  haiway/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  haiway/context/__init__.py,sha256=feqd0eJnGQwh4B8BZXpS0fQRE-DqoFCFOHipF1jOY8A,762
4
4
  haiway/context/access.py,sha256=yW6GNZtSWaxtBRTViP3BiJJYEsLbKkS6Zyzrp1uKgvo,19122
@@ -27,9 +27,9 @@ haiway/types/__init__.py,sha256=-j4uDN6ix3GBXLBqXC-k_QOJSDlO6zvNCxDej8vVzek,342
27
27
  haiway/types/default.py,sha256=h38-zFkbn_UPEiw1SdDF5rkObVmD9UJpmyhOgS1gQ9U,2208
28
28
  haiway/types/frozen.py,sha256=CZhFCXnWAKEhuWSfILxA8smfdpMd5Ku694ycfLh98R8,76
29
29
  haiway/types/missing.py,sha256=rDnyA2wxPkTbJl0L-zbo0owp7IJ04xkCIp6xD6wh8NI,1712
30
- haiway/utils/__init__.py,sha256=JYo5EVquL2BCBsHtvySPTio_x5hSVDJCfu_naWzbqKE,867
30
+ haiway/utils/__init__.py,sha256=VFznJ-kNjuLEqcj5Q6zxzJgvs_KIL7dTZ4FGOf72OcI,907
31
31
  haiway/utils/always.py,sha256=u1tssiErzm0Q3ASc3CV1rLhcMQ54MjpMlC_bRJMQhK4,1230
32
- haiway/utils/collections.py,sha256=IzD-XSEyngKyzLTNG9sr7QjXIneoAzi3oRsDmbRHtzU,3276
32
+ haiway/utils/collections.py,sha256=d1L4rz1LH5b53x03btz-eVxMX55maon2dvQbaDYjvco,4162
33
33
  haiway/utils/env.py,sha256=-hI4CgLkzdyueuECVjm-TfR3lQjE2bDsc72w7vNC4nQ,5339
34
34
  haiway/utils/freezing.py,sha256=K34ZIMzbkpgkHKH-KF73plEbXExsajNRkRTYp9nJEf4,620
35
35
  haiway/utils/logs.py,sha256=oDsc1ZdqKDjlTlctLbDcp9iX98Acr-1tdw-Pyg3DElo,1577
@@ -37,7 +37,7 @@ haiway/utils/mimic.py,sha256=BkVjTVP2TxxC8GChPGyDV6UXVwJmiRiSWeOYZNZFHxs,1828
37
37
  haiway/utils/noop.py,sha256=qgbZlOKWY6_23Zs43OLukK2HagIQKRyR04zrFVm5rWI,344
38
38
  haiway/utils/queue.py,sha256=mF0wayKg6MegfBkgxghPDVCbX2rka6sX7KCzQCGl10s,4120
39
39
  haiway/utils/stream.py,sha256=Vqyi0EwcupkVyKQ7eple6z9DkcbSHkE-6yMw85mak9Q,2832
40
- haiway-0.15.1.dist-info/METADATA,sha256=785O6a47Z95dCqf32Lcz-qRITFRnaj-4LiK1gMIz4mc,4299
41
- haiway-0.15.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
42
- haiway-0.15.1.dist-info/licenses/LICENSE,sha256=3phcpHVNBP8jsi77gOO0E7rgKeDeu99Pi7DSnK9YHoQ,1069
43
- haiway-0.15.1.dist-info/RECORD,,
40
+ haiway-0.15.2.dist-info/METADATA,sha256=7a2-GisdHxpclkxPfGlwN_ih9P4z0laUGNCz4HzlR4U,4299
41
+ haiway-0.15.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
42
+ haiway-0.15.2.dist-info/licenses/LICENSE,sha256=3phcpHVNBP8jsi77gOO0E7rgKeDeu99Pi7DSnK9YHoQ,1069
43
+ haiway-0.15.2.dist-info/RECORD,,