ddeutil-workflow 0.0.77__py3-none-any.whl → 0.0.79__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.
@@ -14,17 +14,17 @@ dates, choices, and complex types like maps and arrays. Each parameter type
14
14
  provides validation and transformation capabilities.
15
15
 
16
16
  Classes:
17
- BaseParam: Abstract base class for all parameter types
18
- DefaultParam: Base class for parameters with default values
19
- DateParam: Date parameter with validation
20
- DatetimeParam: Datetime parameter with validation
21
- StrParam: String parameter type
22
- IntParam: Integer parameter type
23
- FloatParam: Float parameter with precision control
24
- DecimalParam: Decimal parameter for financial calculations
25
- ChoiceParam: Parameter with predefined choices
26
- MapParam: Dictionary/mapping parameter type
27
- ArrayParam: List/array parameter type
17
+ BaseParam: Abstract base class for all parameter types.
18
+ DefaultParam: Base class for parameters with default values.
19
+ DateParam: Date parameter with validation.
20
+ DatetimeParam: Datetime parameter with validation.
21
+ StrParam: String parameter type.
22
+ IntParam: Integer parameter type.
23
+ FloatParam: Float parameter with precision control.
24
+ DecimalParam: Decimal parameter for financial calculations.
25
+ ChoiceParam: Parameter with predefined choices.
26
+ MapParam: Dictionary/mapping parameter type.
27
+ ArrayParam: List/array parameter type.
28
28
 
29
29
  Example:
30
30
  ```python
@@ -58,8 +58,11 @@ T = TypeVar("T")
58
58
 
59
59
 
60
60
  class BaseParam(BaseModel, ABC):
61
- """Base Parameter that use to make any Params Models. The parameter type
62
- will dynamic with the setup type field that made from literal string.
61
+ """Base Parameter that use to make any Params Models.
62
+
63
+ The parameter type will dynamic with the setup type field that made from
64
+ literal string. This abstract base class provides the foundation for all
65
+ parameter types with common validation and processing capabilities.
63
66
  """
64
67
 
65
68
  desc: Optional[str] = Field(
@@ -76,15 +79,28 @@ class BaseParam(BaseModel, ABC):
76
79
 
77
80
  @abstractmethod
78
81
  def receive(self, value: Optional[T] = None) -> T:
79
- """Abstract method receive value to this parameter model."""
82
+ """Abstract method receive value to this parameter model.
83
+
84
+ Args:
85
+ value: The value to validate and process.
86
+
87
+ Returns:
88
+ T: The validated and processed value.
89
+
90
+ Raises:
91
+ NotImplementedError: If not implemented by subclass.
92
+ """
80
93
  raise NotImplementedError(
81
94
  "Receive value and validate typing before return valid value."
82
95
  )
83
96
 
84
97
 
85
98
  class DefaultParam(BaseParam, ABC):
86
- """Default Parameter that will check default if it required. This model do
87
- not implement the `receive` method.
99
+ """Default Parameter that will check default if it required.
100
+
101
+ This model extends BaseParam and provides default value handling capabilities.
102
+ It does not implement the `receive` method, which must be implemented by
103
+ concrete subclasses.
88
104
  """
89
105
 
90
106
  required: bool = Field(
@@ -98,14 +114,29 @@ class DefaultParam(BaseParam, ABC):
98
114
 
99
115
  @abstractmethod
100
116
  def receive(self, value: Optional[Any] = None) -> Any:
101
- """Abstract method receive value to this parameter model."""
117
+ """Abstract method receive value to this parameter model.
118
+
119
+ Args:
120
+ value: The value to validate and process.
121
+
122
+ Returns:
123
+ Any: The validated and processed value.
124
+
125
+ Raises:
126
+ NotImplementedError: If not implemented by subclass.
127
+ """
102
128
  raise NotImplementedError(
103
129
  "Receive value and validate typing before return valid value."
104
130
  )
105
131
 
106
132
 
107
133
  class DateParam(DefaultParam): # pragma: no cov
108
- """Date parameter model."""
134
+ """Date parameter model.
135
+
136
+ This class provides date parameter validation and processing with support
137
+ for various input formats including ISO date strings, datetime objects,
138
+ and date objects.
139
+ """
109
140
 
110
141
  type: Literal["date"] = "date"
111
142
  default: date = Field(
@@ -116,12 +147,18 @@ class DateParam(DefaultParam): # pragma: no cov
116
147
  def receive(
117
148
  self, value: Optional[Union[str, datetime, date]] = None
118
149
  ) -> date:
119
- """Receive value that match with date. If an input value pass with
120
- None, it will use default value instead.
150
+ """Receive value that match with date.
121
151
 
122
- :param value: A value that want to validate with date parameter type.
152
+ If an input value pass with None, it will use default value instead.
123
153
 
124
- :rtype: date
154
+ Args:
155
+ value: A value that want to validate with date parameter type.
156
+
157
+ Returns:
158
+ date: The validated date value.
159
+
160
+ Raises:
161
+ ParamError: If the value cannot be converted to a valid date.
125
162
  """
126
163
  if value is None:
127
164
  return self.default
@@ -144,7 +181,12 @@ class DateParam(DefaultParam): # pragma: no cov
144
181
 
145
182
 
146
183
  class DatetimeParam(DefaultParam):
147
- """Datetime parameter model."""
184
+ """Datetime parameter model.
185
+
186
+ This class provides datetime parameter validation and processing with support
187
+ for various input formats including ISO datetime strings, datetime objects,
188
+ and date objects. All datetime values are normalized to UTC timezone.
189
+ """
148
190
 
149
191
  type: Literal["datetime"] = "datetime"
150
192
  default: datetime = Field(
@@ -157,13 +199,18 @@ class DatetimeParam(DefaultParam):
157
199
  def receive(
158
200
  self, value: Optional[Union[str, datetime, date]] = None
159
201
  ) -> datetime:
160
- """Receive value that match with datetime. If an input value pass with
161
- None, it will use default value instead.
202
+ """Receive value that match with datetime.
203
+
204
+ If an input value pass with None, it will use default value instead.
205
+
206
+ Args:
207
+ value: A value that want to validate with datetime parameter type.
162
208
 
163
- :param value: A value that want to validate with datetime parameter
164
- type.
209
+ Returns:
210
+ datetime: The validated datetime value in UTC timezone.
165
211
 
166
- :rtype: datetime
212
+ Raises:
213
+ ParamError: If the value cannot be converted to a valid datetime.
167
214
  """
168
215
  if value is None:
169
216
  return self.default
@@ -188,16 +235,22 @@ class DatetimeParam(DefaultParam):
188
235
 
189
236
 
190
237
  class StrParam(DefaultParam):
191
- """String parameter."""
238
+ """String parameter.
239
+
240
+ This class provides string parameter validation and processing with support
241
+ for converting various input types to strings.
242
+ """
192
243
 
193
244
  type: Literal["str"] = "str"
194
245
 
195
246
  def receive(self, value: Optional[Any] = None) -> Optional[str]:
196
247
  """Receive value that match with str.
197
248
 
198
- :param value: (Any) A value that want to validate with string parameter
199
- type.
200
- :rtype: Optional[str]
249
+ Args:
250
+ value: A value that want to validate with string parameter type.
251
+
252
+ Returns:
253
+ Optional[str]: The validated string value or None.
201
254
  """
202
255
  if value is None:
203
256
  return self.default
@@ -205,15 +258,25 @@ class StrParam(DefaultParam):
205
258
 
206
259
 
207
260
  class IntParam(DefaultParam):
208
- """Integer parameter."""
261
+ """Integer parameter.
262
+
263
+ This class provides integer parameter validation and processing with support
264
+ for converting various numeric types to integers.
265
+ """
209
266
 
210
267
  type: Literal["int"] = "int"
211
268
 
212
269
  def receive(self, value: Optional[StrOrInt] = None) -> Optional[int]:
213
270
  """Receive value that match with int.
214
271
 
215
- :param value: A value that want to validate with integer parameter type.
216
- :rtype: int | None
272
+ Args:
273
+ value: A value that want to validate with integer parameter type.
274
+
275
+ Returns:
276
+ Optional[int]: The validated integer value or None.
277
+
278
+ Raises:
279
+ ParamError: If the value cannot be converted to an integer.
217
280
  """
218
281
  if value is None:
219
282
  return self.default
@@ -228,7 +291,11 @@ class IntParam(DefaultParam):
228
291
 
229
292
 
230
293
  class FloatParam(DefaultParam): # pragma: no cov
231
- """Float parameter."""
294
+ """Float parameter.
295
+
296
+ This class provides float parameter validation and processing with precision
297
+ control for rounding float values to a specified number of decimal places.
298
+ """
232
299
 
233
300
  type: Literal["float"] = "float"
234
301
  precision: int = 6
@@ -236,9 +303,11 @@ class FloatParam(DefaultParam): # pragma: no cov
236
303
  def rounding(self, value: float) -> float:
237
304
  """Rounding float value with the specific precision field.
238
305
 
239
- :param value: A float value that want to round with the precision value.
306
+ Args:
307
+ value: A float value that want to round with the precision value.
240
308
 
241
- :rtype: float
309
+ Returns:
310
+ float: The rounded float value.
242
311
  """
243
312
  round_str: str = f"{{0:.{self.precision}f}}"
244
313
  return float(round_str.format(round(value, self.precision)))
@@ -248,8 +317,14 @@ class FloatParam(DefaultParam): # pragma: no cov
248
317
  ) -> Optional[float]:
249
318
  """Receive value that match with float.
250
319
 
251
- :param value: A value that want to validate with float parameter type.
252
- :rtype: float | None
320
+ Args:
321
+ value: A value that want to validate with float parameter type.
322
+
323
+ Returns:
324
+ Optional[float]: The validated float value or None.
325
+
326
+ Raises:
327
+ TypeError: If the value type is not supported.
253
328
  """
254
329
  if value is None:
255
330
  return self.default
@@ -266,18 +341,23 @@ class FloatParam(DefaultParam): # pragma: no cov
266
341
 
267
342
 
268
343
  class DecimalParam(DefaultParam): # pragma: no cov
269
- """Decimal parameter."""
344
+ """Decimal parameter.
345
+
346
+ This class provides decimal parameter validation and processing with precision
347
+ control for financial calculations and exact decimal arithmetic.
348
+ """
270
349
 
271
350
  type: Literal["decimal"] = "decimal"
272
351
  precision: int = 6
273
352
 
274
353
  def rounding(self, value: Decimal) -> Decimal:
275
- """Rounding float value with the specific precision field.
354
+ """Rounding decimal value with the specific precision field.
276
355
 
277
- :param value: (Decimal) A Decimal value that want to round with the
278
- precision value.
356
+ Args:
357
+ value: A Decimal value that want to round with the precision value.
279
358
 
280
- :rtype: Decimal
359
+ Returns:
360
+ Decimal: The rounded decimal value.
281
361
  """
282
362
  return value.quantize(Decimal(10) ** -self.precision)
283
363
 
@@ -286,9 +366,15 @@ class DecimalParam(DefaultParam): # pragma: no cov
286
366
  ) -> Decimal:
287
367
  """Receive value that match with decimal.
288
368
 
289
- :param value: (float | Decimal) A value that want to validate with
290
- decimal parameter type.
291
- :rtype: Decimal | None
369
+ Args:
370
+ value: A value that want to validate with decimal parameter type.
371
+
372
+ Returns:
373
+ Decimal: The validated decimal value.
374
+
375
+ Raises:
376
+ TypeError: If the value type is not supported.
377
+ ValueError: If the string cannot be converted to a valid decimal.
292
378
  """
293
379
  if value is None:
294
380
  return self.default
@@ -311,7 +397,11 @@ class DecimalParam(DefaultParam): # pragma: no cov
311
397
 
312
398
 
313
399
  class ChoiceParam(BaseParam):
314
- """Choice parameter."""
400
+ """Choice parameter.
401
+
402
+ This class provides choice parameter validation and processing with support
403
+ for predefined options. If no value is provided, it returns the first option.
404
+ """
315
405
 
316
406
  type: Literal["choice"] = "choice"
317
407
  options: Union[list[str], list[int]] = Field(
@@ -321,9 +411,14 @@ class ChoiceParam(BaseParam):
321
411
  def receive(self, value: Optional[StrOrInt] = None) -> StrOrInt:
322
412
  """Receive value that match with options.
323
413
 
324
- :param value: (str | int) A value that want to select from the options
325
- field.
326
- :rtype: str | int
414
+ Args:
415
+ value: A value that want to select from the options field.
416
+
417
+ Returns:
418
+ StrOrInt: The validated choice value.
419
+
420
+ Raises:
421
+ ParamError: If the value is not in the available options.
327
422
  """
328
423
  # NOTE:
329
424
  # Return the first value in options if it does not pass any input
@@ -338,7 +433,11 @@ class ChoiceParam(BaseParam):
338
433
 
339
434
 
340
435
  class MapParam(DefaultParam):
341
- """Map parameter."""
436
+ """Map parameter.
437
+
438
+ This class provides dictionary/mapping parameter validation and processing
439
+ with support for converting string representations to dictionaries.
440
+ """
342
441
 
343
442
  type: Literal["map"] = "map"
344
443
  default: dict[Any, Any] = Field(
@@ -352,9 +451,14 @@ class MapParam(DefaultParam):
352
451
  ) -> dict[Any, Any]:
353
452
  """Receive value that match with map type.
354
453
 
355
- :param value: A value that want to validate with map parameter type.
454
+ Args:
455
+ value: A value that want to validate with map parameter type.
356
456
 
357
- :rtype: dict[Any, Any]
457
+ Returns:
458
+ dict[Any, Any]: The validated dictionary value.
459
+
460
+ Raises:
461
+ ParamError: If the value cannot be converted to a valid dictionary.
358
462
  """
359
463
  if value is None:
360
464
  return self.default
@@ -376,7 +480,11 @@ class MapParam(DefaultParam):
376
480
 
377
481
 
378
482
  class ArrayParam(DefaultParam):
379
- """Array parameter."""
483
+ """Array parameter.
484
+
485
+ This class provides list/array parameter validation and processing with support
486
+ for converting various sequence types to lists.
487
+ """
380
488
 
381
489
  type: Literal["array"] = "array"
382
490
  default: list[Any] = Field(
@@ -389,8 +497,14 @@ class ArrayParam(DefaultParam):
389
497
  ) -> list[T]:
390
498
  """Receive value that match with array type.
391
499
 
392
- :param value: A value that want to validate with array parameter type.
393
- :rtype: list[Any]
500
+ Args:
501
+ value: A value that want to validate with array parameter type.
502
+
503
+ Returns:
504
+ list[T]: The validated list value.
505
+
506
+ Raises:
507
+ ParamError: If the value cannot be converted to a valid list.
394
508
  """
395
509
  if value is None:
396
510
  return self.default
File without changes
File without changes