haiway 0.10.10__py3-none-any.whl → 0.10.11__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/utils/collections.py +93 -16
- {haiway-0.10.10.dist-info → haiway-0.10.11.dist-info}/METADATA +1 -1
- {haiway-0.10.10.dist-info → haiway-0.10.11.dist-info}/RECORD +5 -5
- {haiway-0.10.10.dist-info → haiway-0.10.11.dist-info}/WHEEL +0 -0
- {haiway-0.10.10.dist-info → haiway-0.10.11.dist-info}/licenses/LICENSE +0 -0
haiway/utils/collections.py
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
3
|
+
Version: 0.10.11
|
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
|
@@ -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=
|
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.
|
40
|
-
haiway-0.10.
|
41
|
-
haiway-0.10.
|
42
|
-
haiway-0.10.
|
39
|
+
haiway-0.10.11.dist-info/METADATA,sha256=Xz9EVwzVcqiYBNaDv0QZQ4gXv3482M9eV9n82ba6kJo,3858
|
40
|
+
haiway-0.10.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
41
|
+
haiway-0.10.11.dist-info/licenses/LICENSE,sha256=GehQEW_I1pkmxkkj3NEa7rCTQKYBn7vTPabpDYJlRuo,1063
|
42
|
+
haiway-0.10.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|