simplibs-types 0.1.0__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.
Files changed (153) hide show
  1. simplibs/types/__init__.py +285 -0
  2. simplibs/types/collections/__init__.py +18 -0
  3. simplibs/types/collections/dict/__init__.py +24 -0
  4. simplibs/types/collections/dict/direct/__init__.py +0 -0
  5. simplibs/types/collections/dict/direct/dict_not_empty.py +18 -0
  6. simplibs/types/collections/dict/parametrized/__init__.py +0 -0
  7. simplibs/types/collections/dict/parametrized/dict_length.py +23 -0
  8. simplibs/types/collections/dict/parametrized/dict_max_length.py +23 -0
  9. simplibs/types/collections/dict/parametrized/dict_min_length.py +23 -0
  10. simplibs/types/collections/list/__init__.py +30 -0
  11. simplibs/types/collections/list/direct/__init__.py +0 -0
  12. simplibs/types/collections/list/direct/list_not_empty.py +18 -0
  13. simplibs/types/collections/list/direct/list_unique.py +18 -0
  14. simplibs/types/collections/list/direct/list_unique_not_empty.py +19 -0
  15. simplibs/types/collections/list/parametrized/__init__.py +0 -0
  16. simplibs/types/collections/list/parametrized/list_length.py +22 -0
  17. simplibs/types/collections/list/parametrized/list_max_length.py +23 -0
  18. simplibs/types/collections/list/parametrized/list_min_length.py +23 -0
  19. simplibs/types/collections/list/parametrized/list_of.py +30 -0
  20. simplibs/types/collections/set/__init__.py +26 -0
  21. simplibs/types/collections/set/direct/__init__.py +0 -0
  22. simplibs/types/collections/set/direct/set_not_empty.py +18 -0
  23. simplibs/types/collections/set/parametrized/__init__.py +0 -0
  24. simplibs/types/collections/set/parametrized/set_length.py +22 -0
  25. simplibs/types/collections/set/parametrized/set_max_length.py +23 -0
  26. simplibs/types/collections/set/parametrized/set_min_length.py +23 -0
  27. simplibs/types/collections/set/parametrized/set_of.py +31 -0
  28. simplibs/types/collections/tuple/__init__.py +26 -0
  29. simplibs/types/collections/tuple/direct/__init__.py +0 -0
  30. simplibs/types/collections/tuple/direct/tuple_not_empty.py +18 -0
  31. simplibs/types/collections/tuple/parametrized/__init__.py +0 -0
  32. simplibs/types/collections/tuple/parametrized/tuple_length.py +22 -0
  33. simplibs/types/collections/tuple/parametrized/tuple_max_length.py +23 -0
  34. simplibs/types/collections/tuple/parametrized/tuple_min_length.py +23 -0
  35. simplibs/types/collections/tuple/parametrized/tuple_of.py +32 -0
  36. simplibs/types/primitives/__init__.py +20 -0
  37. simplibs/types/primitives/bool/__init__.py +18 -0
  38. simplibs/types/primitives/bool/direct/__init__.py +0 -0
  39. simplibs/types/primitives/bool/direct/bool_false.py +18 -0
  40. simplibs/types/primitives/bool/direct/bool_true.py +18 -0
  41. simplibs/types/primitives/bytes/__init__.py +28 -0
  42. simplibs/types/primitives/bytes/direct/__init__.py +0 -0
  43. simplibs/types/primitives/bytes/direct/bytes_empty.py +18 -0
  44. simplibs/types/primitives/bytes/direct/bytes_not_empty.py +18 -0
  45. simplibs/types/primitives/bytes/parametrized/__init__.py +0 -0
  46. simplibs/types/primitives/bytes/parametrized/bytes_length.py +22 -0
  47. simplibs/types/primitives/bytes/parametrized/bytes_length_range.py +25 -0
  48. simplibs/types/primitives/bytes/parametrized/bytes_max_length.py +23 -0
  49. simplibs/types/primitives/bytes/parametrized/bytes_min_length.py +23 -0
  50. simplibs/types/primitives/float/__init__.py +53 -0
  51. simplibs/types/primitives/float/direct/__init__.py +0 -0
  52. simplibs/types/primitives/float/direct/float_finite.py +18 -0
  53. simplibs/types/primitives/float/direct/float_latitude.py +18 -0
  54. simplibs/types/primitives/float/direct/float_longitude.py +18 -0
  55. simplibs/types/primitives/float/direct/float_negative.py +18 -0
  56. simplibs/types/primitives/float/direct/float_non_negative.py +18 -0
  57. simplibs/types/primitives/float/direct/float_non_positive.py +18 -0
  58. simplibs/types/primitives/float/direct/float_not_infinite.py +23 -0
  59. simplibs/types/primitives/float/direct/float_not_nan.py +23 -0
  60. simplibs/types/primitives/float/direct/float_not_zero.py +18 -0
  61. simplibs/types/primitives/float/direct/float_percentage.py +18 -0
  62. simplibs/types/primitives/float/direct/float_positive.py +18 -0
  63. simplibs/types/primitives/float/direct/float_probability.py +18 -0
  64. simplibs/types/primitives/float/direct/float_zero.py +18 -0
  65. simplibs/types/primitives/float/parametrized/__init__.py +0 -0
  66. simplibs/types/primitives/float/parametrized/float_ge.py +22 -0
  67. simplibs/types/primitives/float/parametrized/float_gt.py +22 -0
  68. simplibs/types/primitives/float/parametrized/float_in_range.py +23 -0
  69. simplibs/types/primitives/float/parametrized/float_le.py +22 -0
  70. simplibs/types/primitives/float/parametrized/float_lt.py +22 -0
  71. simplibs/types/primitives/int/__init__.py +77 -0
  72. simplibs/types/primitives/int/direct/__init__.py +0 -0
  73. simplibs/types/primitives/int/direct/int_day_of_month.py +24 -0
  74. simplibs/types/primitives/int/direct/int_even.py +18 -0
  75. simplibs/types/primitives/int/direct/int_hour.py +18 -0
  76. simplibs/types/primitives/int/direct/int_int8.py +18 -0
  77. simplibs/types/primitives/int/direct/int_minute.py +18 -0
  78. simplibs/types/primitives/int/direct/int_month.py +18 -0
  79. simplibs/types/primitives/int/direct/int_negative.py +18 -0
  80. simplibs/types/primitives/int/direct/int_non_negative.py +18 -0
  81. simplibs/types/primitives/int/direct/int_non_negative_even.py +19 -0
  82. simplibs/types/primitives/int/direct/int_non_positive.py +18 -0
  83. simplibs/types/primitives/int/direct/int_not_zero.py +18 -0
  84. simplibs/types/primitives/int/direct/int_odd.py +18 -0
  85. simplibs/types/primitives/int/direct/int_percentage.py +18 -0
  86. simplibs/types/primitives/int/direct/int_port.py +18 -0
  87. simplibs/types/primitives/int/direct/int_positive.py +18 -0
  88. simplibs/types/primitives/int/direct/int_positive_even.py +19 -0
  89. simplibs/types/primitives/int/direct/int_positive_odd.py +19 -0
  90. simplibs/types/primitives/int/direct/int_second.py +22 -0
  91. simplibs/types/primitives/int/direct/int_uint8.py +18 -0
  92. simplibs/types/primitives/int/direct/int_year.py +18 -0
  93. simplibs/types/primitives/int/direct/int_zero.py +18 -0
  94. simplibs/types/primitives/int/parametrized/__init__.py +0 -0
  95. simplibs/types/primitives/int/parametrized/int_divisible_by.py +22 -0
  96. simplibs/types/primitives/int/parametrized/int_eq.py +22 -0
  97. simplibs/types/primitives/int/parametrized/int_ge.py +23 -0
  98. simplibs/types/primitives/int/parametrized/int_gt.py +22 -0
  99. simplibs/types/primitives/int/parametrized/int_in_range.py +23 -0
  100. simplibs/types/primitives/int/parametrized/int_le.py +22 -0
  101. simplibs/types/primitives/int/parametrized/int_lt.py +22 -0
  102. simplibs/types/primitives/int/parametrized/int_multiple_of.py +29 -0
  103. simplibs/types/primitives/int/parametrized/int_ne.py +22 -0
  104. simplibs/types/primitives/int_float/__init__.py +32 -0
  105. simplibs/types/primitives/int_float/direct/__init__.py +0 -0
  106. simplibs/types/primitives/int_float/direct/int_float_finite.py +25 -0
  107. simplibs/types/primitives/int_float/direct/int_float_negative.py +19 -0
  108. simplibs/types/primitives/int_float/direct/int_float_non_negative.py +19 -0
  109. simplibs/types/primitives/int_float/direct/int_float_non_positive.py +19 -0
  110. simplibs/types/primitives/int_float/direct/int_float_not_zero.py +18 -0
  111. simplibs/types/primitives/int_float/direct/int_float_positive.py +19 -0
  112. simplibs/types/primitives/int_float/direct/int_float_zero.py +18 -0
  113. simplibs/types/primitives/int_float/parametrized/__init__.py +0 -0
  114. simplibs/types/primitives/int_float/parametrized/int_float_in_range.py +23 -0
  115. simplibs/types/primitives/str/__init__.py +79 -0
  116. simplibs/types/primitives/str/direct/__init__.py +0 -0
  117. simplibs/types/primitives/str/direct/str_alnum.py +20 -0
  118. simplibs/types/primitives/str/direct/str_alpha.py +19 -0
  119. simplibs/types/primitives/str/direct/str_ascii.py +18 -0
  120. simplibs/types/primitives/str/direct/str_blank.py +18 -0
  121. simplibs/types/primitives/str/direct/str_digit.py +18 -0
  122. simplibs/types/primitives/str/direct/str_email.py +24 -0
  123. simplibs/types/primitives/str/direct/str_empty.py +18 -0
  124. simplibs/types/primitives/str/direct/str_hex_color.py +19 -0
  125. simplibs/types/primitives/str/direct/str_identifier.py +18 -0
  126. simplibs/types/primitives/str/direct/str_lower.py +18 -0
  127. simplibs/types/primitives/str/direct/str_no_whitespace.py +19 -0
  128. simplibs/types/primitives/str/direct/str_not_blank.py +19 -0
  129. simplibs/types/primitives/str/direct/str_not_empty.py +23 -0
  130. simplibs/types/primitives/str/direct/str_printable.py +20 -0
  131. simplibs/types/primitives/str/direct/str_single_line.py +19 -0
  132. simplibs/types/primitives/str/direct/str_slug.py +20 -0
  133. simplibs/types/primitives/str/direct/str_snake_case.py +21 -0
  134. simplibs/types/primitives/str/direct/str_title.py +18 -0
  135. simplibs/types/primitives/str/direct/str_upper.py +18 -0
  136. simplibs/types/primitives/str/direct/str_url.py +23 -0
  137. simplibs/types/primitives/str/direct/str_uuid.py +19 -0
  138. simplibs/types/primitives/str/direct/str_whitespace.py +20 -0
  139. simplibs/types/primitives/str/parametrized/__init__.py +0 -0
  140. simplibs/types/primitives/str/parametrized/str_contains.py +23 -0
  141. simplibs/types/primitives/str/parametrized/str_ends_with.py +22 -0
  142. simplibs/types/primitives/str/parametrized/str_length.py +23 -0
  143. simplibs/types/primitives/str/parametrized/str_length_range.py +25 -0
  144. simplibs/types/primitives/str/parametrized/str_matches.py +23 -0
  145. simplibs/types/primitives/str/parametrized/str_max_length.py +23 -0
  146. simplibs/types/primitives/str/parametrized/str_min_length.py +23 -0
  147. simplibs/types/primitives/str/parametrized/str_one_of.py +23 -0
  148. simplibs/types/primitives/str/parametrized/str_starts_with.py +22 -0
  149. simplibs_types-0.1.0.dist-info/METADATA +429 -0
  150. simplibs_types-0.1.0.dist-info/RECORD +153 -0
  151. simplibs_types-0.1.0.dist-info/WHEEL +5 -0
  152. simplibs_types-0.1.0.dist-info/licenses/LICENSE +21 -0
  153. simplibs_types-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,285 @@
1
+ from .collections.dict import (
2
+ dict_not_empty,
3
+ dict_length,
4
+ dict_min_length,
5
+ dict_max_length,
6
+ )
7
+ from .collections.list import (
8
+ list_not_empty,
9
+ list_unique,
10
+ list_unique_not_empty,
11
+ list_of,
12
+ list_length,
13
+ list_min_length,
14
+ list_max_length,
15
+ )
16
+ from .collections.set import (
17
+ set_not_empty,
18
+ set_of,
19
+ set_length,
20
+ set_min_length,
21
+ set_max_length,
22
+ )
23
+ from .collections.tuple import (
24
+ tuple_not_empty,
25
+ tuple_of,
26
+ tuple_length,
27
+ tuple_min_length,
28
+ tuple_max_length,
29
+ )
30
+ from .primitives.bool import (
31
+ bool_true,
32
+ bool_false,
33
+ )
34
+ from .primitives.bytes import (
35
+ bytes_empty,
36
+ bytes_not_empty,
37
+ bytes_length,
38
+ bytes_min_length,
39
+ bytes_max_length,
40
+ bytes_length_range,
41
+ )
42
+ from .primitives.float import (
43
+ float_positive,
44
+ float_negative,
45
+ float_non_negative,
46
+ float_non_positive,
47
+ float_zero,
48
+ float_not_zero,
49
+ float_finite,
50
+ float_not_nan,
51
+ float_not_infinite,
52
+ float_probability,
53
+ float_percentage,
54
+ float_latitude,
55
+ float_longitude,
56
+ float_gt,
57
+ float_ge,
58
+ float_lt,
59
+ float_le,
60
+ float_in_range,
61
+ )
62
+ from .primitives.int import (
63
+ int_positive,
64
+ int_negative,
65
+ int_non_negative,
66
+ int_non_positive,
67
+ int_zero,
68
+ int_not_zero,
69
+ int_even,
70
+ int_odd,
71
+ int_positive_even,
72
+ int_positive_odd,
73
+ int_non_negative_even,
74
+ int_uint8,
75
+ int_int8,
76
+ int_percentage,
77
+ int_port,
78
+ int_year,
79
+ int_month,
80
+ int_day_of_month,
81
+ int_hour,
82
+ int_minute,
83
+ int_second,
84
+ int_gt,
85
+ int_ge,
86
+ int_lt,
87
+ int_le,
88
+ int_eq,
89
+ int_ne,
90
+ int_in_range,
91
+ int_divisible_by,
92
+ int_multiple_of,
93
+ )
94
+ from .primitives.int_float import (
95
+ int_float_positive,
96
+ int_float_negative,
97
+ int_float_non_negative,
98
+ int_float_non_positive,
99
+ int_float_zero,
100
+ int_float_not_zero,
101
+ int_float_finite,
102
+ int_float_in_range,
103
+ )
104
+ from .primitives.str import (
105
+ str_empty,
106
+ str_not_empty,
107
+ str_blank,
108
+ str_not_blank,
109
+ str_whitespace,
110
+ str_alpha,
111
+ str_alnum,
112
+ str_digit,
113
+ str_ascii,
114
+ str_printable,
115
+ str_lower,
116
+ str_upper,
117
+ str_title,
118
+ str_no_whitespace,
119
+ str_single_line,
120
+ str_identifier,
121
+ str_slug,
122
+ str_snake_case,
123
+ str_email,
124
+ str_url,
125
+ str_uuid,
126
+ str_hex_color,
127
+ str_length,
128
+ str_min_length,
129
+ str_max_length,
130
+ str_length_range,
131
+ str_starts_with,
132
+ str_ends_with,
133
+ str_contains,
134
+ str_matches,
135
+ str_one_of,
136
+ )
137
+
138
+
139
+ __all__ = [
140
+ # collections/dict
141
+ "dict_not_empty",
142
+ "dict_length",
143
+ "dict_min_length",
144
+ "dict_max_length",
145
+ # collections/list
146
+ "list_not_empty",
147
+ "list_unique",
148
+ "list_unique_not_empty",
149
+ "list_of",
150
+ "list_length",
151
+ "list_min_length",
152
+ "list_max_length",
153
+ # collections/set
154
+ "set_not_empty",
155
+ "set_of",
156
+ "set_length",
157
+ "set_min_length",
158
+ "set_max_length",
159
+ # collections/tuple
160
+ "tuple_not_empty",
161
+ "tuple_of",
162
+ "tuple_length",
163
+ "tuple_min_length",
164
+ "tuple_max_length",
165
+ # types/bool
166
+ "bool_true",
167
+ "bool_false",
168
+ # types/bytes
169
+ "bytes_empty",
170
+ "bytes_not_empty",
171
+ "bytes_length",
172
+ "bytes_min_length",
173
+ "bytes_max_length",
174
+ "bytes_length_range",
175
+ # types/float
176
+ "float_positive",
177
+ "float_negative",
178
+ "float_non_negative",
179
+ "float_non_positive",
180
+ "float_zero",
181
+ "float_not_zero",
182
+ "float_finite",
183
+ "float_not_nan",
184
+ "float_not_infinite",
185
+ "float_probability",
186
+ "float_percentage",
187
+ "float_latitude",
188
+ "float_longitude",
189
+ "float_gt",
190
+ "float_ge",
191
+ "float_lt",
192
+ "float_le",
193
+ "float_in_range",
194
+ # types/int
195
+ "int_positive",
196
+ "int_negative",
197
+ "int_non_negative",
198
+ "int_non_positive",
199
+ "int_zero",
200
+ "int_not_zero",
201
+ "int_even",
202
+ "int_odd",
203
+ "int_positive_even",
204
+ "int_positive_odd",
205
+ "int_non_negative_even",
206
+ "int_uint8",
207
+ "int_int8",
208
+ "int_percentage",
209
+ "int_port",
210
+ "int_year",
211
+ "int_month",
212
+ "int_day_of_month",
213
+ "int_hour",
214
+ "int_minute",
215
+ "int_second",
216
+ "int_gt",
217
+ "int_ge",
218
+ "int_lt",
219
+ "int_le",
220
+ "int_eq",
221
+ "int_ne",
222
+ "int_in_range",
223
+ "int_divisible_by",
224
+ "int_multiple_of",
225
+ # types/int_float
226
+ "int_float_positive",
227
+ "int_float_negative",
228
+ "int_float_non_negative",
229
+ "int_float_non_positive",
230
+ "int_float_zero",
231
+ "int_float_not_zero",
232
+ "int_float_finite",
233
+ "int_float_in_range",
234
+ # types/str
235
+ "str_empty",
236
+ "str_not_empty",
237
+ "str_blank",
238
+ "str_not_blank",
239
+ "str_whitespace",
240
+ "str_alpha",
241
+ "str_alnum",
242
+ "str_digit",
243
+ "str_ascii",
244
+ "str_printable",
245
+ "str_lower",
246
+ "str_upper",
247
+ "str_title",
248
+ "str_no_whitespace",
249
+ "str_single_line",
250
+ "str_identifier",
251
+ "str_slug",
252
+ "str_snake_case",
253
+ "str_email",
254
+ "str_url",
255
+ "str_uuid",
256
+ "str_hex_color",
257
+ "str_length",
258
+ "str_min_length",
259
+ "str_max_length",
260
+ "str_length_range",
261
+ "str_starts_with",
262
+ "str_ends_with",
263
+ "str_contains",
264
+ "str_matches",
265
+ "str_one_of",
266
+ ]
267
+
268
+
269
+ _DESIGN_NOTES = """
270
+ # simplibs-types — Package Overview
271
+
272
+ ## Purpose
273
+ The top-level entry point of `simplibs-types`. Re-exports ready-made
274
+ preset type from `presets/colections` and `presets/types`, so a caller
275
+ never has to reach into the internal folder structure directly:
276
+
277
+ from simplibs.types import int_positive, str_email, validated_type
278
+
279
+ ## Internal Components Registry
280
+
281
+ | Component | Type | Description |
282
+ | :---------------------- | :-------- | :-------------------------------------------------------------------- |
283
+ | `presets.colections.*` | Sub-Package | Container presets (`dict`, `list`, `set`, `tuple`). |
284
+ | `presets.types.*` | Sub-Package | Scalar type presets (`bool`, `bytes`, `float`, `int`, `number`, `str`).|
285
+ """
@@ -0,0 +1,18 @@
1
+ # src/simplibs/03_simplibs-types/presets/colections/__init__.py
2
+ _DESIGN_NOTES = """
3
+ # Collections Presets Package
4
+
5
+ ## Purpose
6
+ Validated types for the four built-in container types. Each sub-package
7
+ groups one container's presets (non-emptiness, length constraints, item
8
+ uniqueness, per-item validation via `*_of` factories).
9
+
10
+ ## Internal Components Registry
11
+
12
+ | Component | Type | Description |
13
+ | :---------- | :-------- | :--------------------------------------------------- |
14
+ | `dict` | Sub-Package | Presets for `dict` (emptiness, length). |
15
+ | `list` | Sub-Package | Presets for `list` (emptiness, uniqueness, length, `list_of`). |
16
+ | `set` | Sub-Package | Presets for `set` (emptiness, length, `set_of`). |
17
+ | `tuple` | Sub-Package | Presets for `tuple` (emptiness, length, `tuple_of`). |
18
+ """
@@ -0,0 +1,24 @@
1
+ # Direct:
2
+ from .direct.dict_not_empty import dict_not_empty
3
+ # Parametric:
4
+ from .parametrized.dict_length import dict_length
5
+ from .parametrized.dict_min_length import dict_min_length
6
+ from .parametrized.dict_max_length import dict_max_length
7
+
8
+
9
+ _DESIGN_NOTES = """
10
+ # Dict Presets Sub-Package
11
+
12
+ ## Purpose
13
+ Validated types for `dict` — non-emptiness and length constraints (exact,
14
+ minimum, maximum number of key-value pairs).
15
+
16
+ ## Internal Components Registry
17
+
18
+ | Component | Type | Description |
19
+ | :------------------ | :-------------- | :---------------------------------------------- |
20
+ | `dict_not_empty` | Validated Type | Non-empty dictionary. |
21
+ | `dict_length` | Factory | Dictionary with an exact number of items. |
22
+ | `dict_min_length` | Factory | Dictionary with a minimum number of items. |
23
+ | `dict_max_length` | Factory | Dictionary with a maximum number of items. |
24
+ """
File without changes
@@ -0,0 +1,18 @@
1
+ from simplibs.validate import validated_type
2
+ from simplibs.rules import not_empty
3
+
4
+
5
+ dict_not_empty = validated_type(dict, not_empty)
6
+ """Validated type for a non-empty dictionary.
7
+
8
+ Init Params:
9
+ (no parameters)
10
+
11
+ Validation pipeline:
12
+ 1. Value must be of type `dict`.
13
+ 2. Value must not be empty (must contain at least one item).
14
+
15
+ Example:
16
+ @validate_call
17
+ def process(data: dict_not_empty): ...
18
+ """
@@ -0,0 +1,23 @@
1
+ from typing import Any
2
+ from simplibs.validate import validated_type
3
+ from simplibs.rules import has_length
4
+
5
+
6
+ def dict_length(exact: int) -> Any:
7
+ """Validated type for a dictionary with an exact number of items.
8
+
9
+ Init Params:
10
+ exact (int): The exact number of key-value pairs the dictionary
11
+ must contain.
12
+
13
+ Validation pipeline:
14
+ 1. Value must be of type `dict`.
15
+ 2. Value's length must equal `exact`.
16
+
17
+ Example:
18
+ ThreeItemDict = dict_length(3)
19
+
20
+ @validate_call
21
+ def process(data: ThreeItemDict): ...
22
+ """
23
+ return validated_type(dict, has_length(exact))
@@ -0,0 +1,23 @@
1
+ from typing import Any
2
+ from simplibs.validate import validated_type
3
+ from simplibs.rules import has_length
4
+
5
+
6
+ def dict_max_length(max_length: int) -> Any:
7
+ """Validated type for a dictionary with a maximum number of items.
8
+
9
+ Init Params:
10
+ max_length (int): The maximum number of key-value pairs the
11
+ dictionary may contain (inclusive).
12
+
13
+ Validation pipeline:
14
+ 1. Value must be of type `dict`.
15
+ 2. Value's length must be less than or equal to `max_length`.
16
+
17
+ Example:
18
+ SmallDict = dict_max_length(10)
19
+
20
+ @validate_call
21
+ def process(data: SmallDict): ...
22
+ """
23
+ return validated_type(dict, has_length(max_length=max_length))
@@ -0,0 +1,23 @@
1
+ from typing import Any
2
+ from simplibs.validate import validated_type
3
+ from simplibs.rules import has_length
4
+
5
+
6
+ def dict_min_length(min_length: int) -> Any:
7
+ """Validated type for a dictionary with a minimum number of items.
8
+
9
+ Init Params:
10
+ min_length (int): The minimum number of key-value pairs the
11
+ dictionary must contain (inclusive).
12
+
13
+ Validation pipeline:
14
+ 1. Value must be of type `dict`.
15
+ 2. Value's length must be greater than or equal to `min_length`.
16
+
17
+ Example:
18
+ NonTrivialDict = dict_min_length(2)
19
+
20
+ @validate_call
21
+ def process(data: NonTrivialDict): ...
22
+ """
23
+ return validated_type(dict, has_length(min_length=min_length))
@@ -0,0 +1,30 @@
1
+ # Direct:
2
+ from .direct.list_not_empty import list_not_empty
3
+ from .direct.list_unique import list_unique
4
+ from .direct.list_unique_not_empty import list_unique_not_empty
5
+ # Parametric:
6
+ from .parametrized.list_of import list_of
7
+ from .parametrized.list_length import list_length
8
+ from .parametrized.list_min_length import list_min_length
9
+ from .parametrized.list_max_length import list_max_length
10
+
11
+
12
+ _DESIGN_NOTES = """
13
+ # List Presets Sub-Package
14
+
15
+ ## Purpose
16
+ Validated types for `list` — non-emptiness, item uniqueness, per-item
17
+ validation via `list_of`, and length constraints (exact, minimum, maximum).
18
+
19
+ ## Internal Components Registry
20
+
21
+ | Component | Type | Description |
22
+ | :----------------------- | :-------------- | :-------------------------------------------------- |
23
+ | `list_not_empty` | Validated Type | Non-empty list. |
24
+ | `list_unique` | Validated Type | List with all unique items. |
25
+ | `list_unique_not_empty` | Validated Type | Non-empty list with all unique items. |
26
+ | `list_of` | Factory | List whose every item satisfies a given rule. |
27
+ | `list_length` | Factory | List with an exact number of items. |
28
+ | `list_min_length` | Factory | List with a minimum number of items. |
29
+ | `list_max_length` | Factory | List with a maximum number of items. |
30
+ """
File without changes
@@ -0,0 +1,18 @@
1
+ from simplibs.validate import validated_type
2
+ from simplibs.rules import not_empty
3
+
4
+
5
+ list_not_empty = validated_type(list, not_empty)
6
+ """Validated type for a non-empty list.
7
+
8
+ Init Params:
9
+ (no parameters)
10
+
11
+ Validation pipeline:
12
+ 1. Value must be of type `list`.
13
+ 2. Value must not be empty (must contain at least one item).
14
+
15
+ Example:
16
+ @validate_call
17
+ def process(items: list_not_empty): ...
18
+ """
@@ -0,0 +1,18 @@
1
+ from simplibs.validate import validated_type
2
+ from simplibs.rules import all_unique
3
+
4
+
5
+ list_unique = validated_type(list, all_unique)
6
+ """Validated type for a list whose items are all unique.
7
+
8
+ Init Params:
9
+ (no parameters)
10
+
11
+ Validation pipeline:
12
+ 1. Value must be of type `list`.
13
+ 2. All items in the list must be unique (no duplicates).
14
+
15
+ Example:
16
+ @validate_call
17
+ def process(items: list_unique): ...
18
+ """
@@ -0,0 +1,19 @@
1
+ from simplibs.validate import validated_type
2
+ from simplibs.rules import not_empty, all_unique
3
+
4
+
5
+ list_unique_not_empty = validated_type(list, not_empty & all_unique)
6
+ """Validated type for a non-empty list whose items are all unique.
7
+
8
+ Init Params:
9
+ (no parameters)
10
+
11
+ Validation pipeline:
12
+ 1. Value must be of type `list`.
13
+ 2. Value must not be empty (must contain at least one item).
14
+ 3. All items in the list must be unique (no duplicates).
15
+
16
+ Example:
17
+ @validate_call
18
+ def process(items: list_unique_not_empty): ...
19
+ """
@@ -0,0 +1,22 @@
1
+ from typing import Any
2
+ from simplibs.validate import validated_type
3
+ from simplibs.rules import has_length
4
+
5
+
6
+ def list_length(exact: int) -> Any:
7
+ """Validated type for a list with an exact number of items.
8
+
9
+ Init Params:
10
+ exact (int): The exact number of items the list must contain.
11
+
12
+ Validation pipeline:
13
+ 1. Value must be of type `list`.
14
+ 2. Value's length must equal `exact`.
15
+
16
+ Example:
17
+ TripletList = list_length(3)
18
+
19
+ @validate_call
20
+ def process(items: TripletList): ...
21
+ """
22
+ return validated_type(list, has_length(exact))
@@ -0,0 +1,23 @@
1
+ from typing import Any
2
+ from simplibs.validate import validated_type
3
+ from simplibs.rules import has_length
4
+
5
+
6
+ def list_max_length(max_length: int) -> Any:
7
+ """Validated type for a list with a maximum number of items.
8
+
9
+ Init Params:
10
+ max_length (int): The maximum number of items the list may
11
+ contain (inclusive).
12
+
13
+ Validation pipeline:
14
+ 1. Value must be of type `list`.
15
+ 2. Value's length must be less than or equal to `max_length`.
16
+
17
+ Example:
18
+ SmallList = list_max_length(10)
19
+
20
+ @validate_call
21
+ def process(items: SmallList): ...
22
+ """
23
+ return validated_type(list, has_length(max_length=max_length))
@@ -0,0 +1,23 @@
1
+ from typing import Any
2
+ from simplibs.validate import validated_type
3
+ from simplibs.rules import has_length
4
+
5
+
6
+ def list_min_length(min_length: int) -> Any:
7
+ """Validated type for a list with a minimum number of items.
8
+
9
+ Init Params:
10
+ min_length (int): The minimum number of items the list must
11
+ contain (inclusive).
12
+
13
+ Validation pipeline:
14
+ 1. Value must be of type `list`.
15
+ 2. Value's length must be greater than or equal to `min_length`.
16
+
17
+ Example:
18
+ NonTrivialList = list_min_length(2)
19
+
20
+ @validate_call
21
+ def process(items: NonTrivialList): ...
22
+ """
23
+ return validated_type(list, has_length(min_length=min_length))
@@ -0,0 +1,30 @@
1
+ from typing import Any
2
+ from simplibs.validate import validated_type
3
+ from simplibs.rules import for_each
4
+
5
+
6
+ def list_of(item_rule: Any) -> Any:
7
+ """Validated type for a list whose every item satisfies a given rule.
8
+
9
+ Init Params:
10
+ item_rule (Rule | Callable[[Any], bool]): Rule that every single
11
+ item of the list must satisfy.
12
+
13
+ Validation pipeline:
14
+ 1. Value must be of type `list`.
15
+ 2. Every item of the list must satisfy `item_rule`.
16
+
17
+ Detailed description:
18
+ `item_rule` is applied to each item individually (see `for_each`) —
19
+ if validation fails for a single item, validation of the whole
20
+ list fails. `item_rule` itself may be an arbitrarily composed rule
21
+ (e.g. via `&`, `|`, `~`), including another `validated_type` used
22
+ as a nested annotation.
23
+
24
+ Example:
25
+ PositiveIntList = list_of(greater_than(0))
26
+
27
+ @validate_call
28
+ def register(scores: PositiveIntList): ...
29
+ """
30
+ return validated_type(list, for_each(item_rule))
@@ -0,0 +1,26 @@
1
+ # Direct:
2
+ from .direct.set_not_empty import set_not_empty
3
+ # Parametric:
4
+ from .parametrized.set_of import set_of
5
+ from .parametrized.set_length import set_length
6
+ from .parametrized.set_min_length import set_min_length
7
+ from .parametrized.set_max_length import set_max_length
8
+
9
+
10
+ _DESIGN_NOTES = """
11
+ # Set Presets Sub-Package
12
+
13
+ ## Purpose
14
+ Validated types for `set` — non-emptiness, per-item validation via
15
+ `set_of`, and length constraints (exact, minimum, maximum).
16
+
17
+ ## Internal Components Registry
18
+
19
+ | Component | Type | Description |
20
+ | :----------------- | :-------------- | :----------------------------------------------- |
21
+ | `set_not_empty` | Validated Type | Non-empty set. |
22
+ | `set_of` | Factory | Set whose every item satisfies a given rule. |
23
+ | `set_length` | Factory | Set with an exact number of items. |
24
+ | `set_min_length` | Factory | Set with a minimum number of items. |
25
+ | `set_max_length` | Factory | Set with a maximum number of items. |
26
+ """
File without changes
@@ -0,0 +1,18 @@
1
+ from simplibs.validate import validated_type
2
+ from simplibs.rules import not_empty
3
+
4
+
5
+ set_not_empty = validated_type(set, not_empty)
6
+ """Validated type for a non-empty set.
7
+
8
+ Init Params:
9
+ (no parameters)
10
+
11
+ Validation pipeline:
12
+ 1. Value must be of type `set`.
13
+ 2. Value must not be empty (must contain at least one item).
14
+
15
+ Example:
16
+ @validate_call
17
+ def process(items: set_not_empty): ...
18
+ """