orionis 0.434.0__py3-none-any.whl → 0.436.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.
- orionis/metadata/framework.py +1 -1
- orionis/services/asynchrony/contracts/coroutines.py +5 -10
- orionis/services/asynchrony/coroutines.py +8 -23
- orionis/services/asynchrony/exceptions/exception.py +3 -5
- orionis/services/environment/contracts/caster.py +8 -9
- orionis/services/environment/contracts/env.py +9 -9
- orionis/services/environment/core/dot_env.py +47 -71
- orionis/services/environment/dynamic/caster.py +191 -220
- orionis/services/environment/enums/__init__.py +5 -0
- orionis/services/environment/enums/value_type.py +22 -25
- orionis/services/environment/env.py +28 -12
- orionis/services/environment/exceptions/exception.py +6 -2
- orionis/services/environment/exceptions/value.py +6 -2
- orionis/services/environment/helpers/functions.py +5 -3
- orionis/services/environment/key/key_generator.py +8 -12
- orionis/services/environment/validators/__init__.py +7 -0
- orionis/services/environment/validators/key_name.py +5 -6
- orionis/services/environment/validators/types.py +29 -13
- orionis/test/core/unit_test.py +292 -55
- {orionis-0.434.0.dist-info → orionis-0.436.0.dist-info}/METADATA +1 -1
- {orionis-0.434.0.dist-info → orionis-0.436.0.dist-info}/RECORD +25 -25
- {orionis-0.434.0.dist-info → orionis-0.436.0.dist-info}/WHEEL +0 -0
- {orionis-0.434.0.dist-info → orionis-0.436.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.434.0.dist-info → orionis-0.436.0.dist-info}/top_level.txt +0 -0
- {orionis-0.434.0.dist-info → orionis-0.436.0.dist-info}/zip-safe +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
from typing import Any
|
|
3
2
|
from orionis.services.environment.contracts.caster import IEnvironmentCaster
|
|
4
3
|
from orionis.services.environment.enums.value_type import EnvironmentValueType
|
|
@@ -12,12 +11,12 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
12
11
|
@staticmethod
|
|
13
12
|
def options() -> set:
|
|
14
13
|
"""
|
|
15
|
-
|
|
14
|
+
Get the set of valid type hints supported by this class.
|
|
16
15
|
|
|
17
16
|
Returns
|
|
18
17
|
-------
|
|
19
18
|
set
|
|
20
|
-
|
|
19
|
+
Set of valid type hint strings that can be used for environment value casting.
|
|
21
20
|
"""
|
|
22
21
|
return EnvironmentCaster.OPTIONS
|
|
23
22
|
|
|
@@ -26,15 +25,16 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
26
25
|
raw: str | Any
|
|
27
26
|
) -> None:
|
|
28
27
|
"""
|
|
29
|
-
|
|
28
|
+
Parse the input `raw` to extract a type hint and value for environment variable casting.
|
|
30
29
|
|
|
31
30
|
Parameters
|
|
32
31
|
----------
|
|
33
32
|
raw : str or Any
|
|
34
|
-
The input to be parsed. If a string, it may contain a type hint and value
|
|
35
|
-
(e.g., "int: 42"). If a colon is present, the part before
|
|
36
|
-
and the part after as the value. If no colon
|
|
37
|
-
|
|
33
|
+
The input value to be parsed. If a string, it may contain a type hint and value
|
|
34
|
+
separated by a colon (e.g., "int: 42"). If a colon is present, the part before
|
|
35
|
+
the colon is treated as the type hint and the part after as the value. If no colon
|
|
36
|
+
is present, the entire string is treated as the value with no type hint. If not a
|
|
37
|
+
string, the input is treated as the value with no type hint.
|
|
38
38
|
|
|
39
39
|
Attributes
|
|
40
40
|
----------
|
|
@@ -43,11 +43,12 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
43
43
|
__value_raw : str or Any
|
|
44
44
|
The extracted value string if input is a string, or the raw value otherwise.
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
Notes
|
|
47
|
+
-----
|
|
48
|
+
This constructor does not return a value. It initializes the instance attributes
|
|
49
|
+
for type hint and raw value, which are used for subsequent type casting operations.
|
|
50
50
|
"""
|
|
51
|
+
|
|
51
52
|
# Initialize type hint and value to default None
|
|
52
53
|
self.__type_hint: str = None
|
|
53
54
|
self.__value_raw: str | Any = None
|
|
@@ -68,30 +69,32 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
68
69
|
# Remove leading whitespace from the value part
|
|
69
70
|
self.__value_raw = value_str.lstrip() if value_str else None
|
|
70
71
|
else:
|
|
72
|
+
|
|
71
73
|
# If input is not a string, treat it as the value with no type hint
|
|
72
74
|
self.__value_raw = raw
|
|
73
75
|
|
|
74
76
|
def get(self):
|
|
75
77
|
"""
|
|
76
|
-
|
|
78
|
+
Returns the processed value based on the specified type hint.
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
'
|
|
80
|
+
If a valid type hint is present, this method dispatches to the corresponding
|
|
81
|
+
internal parsing method for that type. Supported type hints include: 'path',
|
|
82
|
+
'str', 'int', 'float', 'bool', 'list', 'dict', 'tuple', 'set', and 'base64'.
|
|
81
83
|
If no type hint is set, the raw value is returned as is.
|
|
82
84
|
|
|
83
85
|
Returns
|
|
84
86
|
-------
|
|
85
87
|
Any
|
|
86
|
-
The value converted or processed according to the specified type hint.
|
|
87
|
-
is set, returns the raw value.
|
|
88
|
+
The value converted or processed according to the specified type hint.
|
|
89
|
+
If no type hint is set, returns the raw value.
|
|
88
90
|
|
|
89
91
|
Raises
|
|
90
92
|
------
|
|
91
93
|
OrionisEnvironmentValueError
|
|
92
|
-
If
|
|
94
|
+
If an error occurs during type conversion or processing.
|
|
93
95
|
"""
|
|
94
96
|
|
|
97
|
+
# Attempt to process the value based on the type hint
|
|
95
98
|
try:
|
|
96
99
|
|
|
97
100
|
# If a type hint is set, dispatch to the appropriate parsing method
|
|
@@ -138,6 +141,7 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
138
141
|
return self.__parseBase64()
|
|
139
142
|
|
|
140
143
|
else:
|
|
144
|
+
|
|
141
145
|
# If no type hint is set, return the raw value
|
|
142
146
|
return self.__value_raw
|
|
143
147
|
|
|
@@ -155,30 +159,31 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
155
159
|
|
|
156
160
|
def to(self, type_hint: str | EnvironmentValueType) -> Any:
|
|
157
161
|
"""
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
This method sets the type hint for the instance and attempts to convert the internal value to the specified type.
|
|
161
|
-
The type hint must be one of the valid options defined in `OPTIONS`. If the conversion is successful, a string
|
|
162
|
-
representation of the value prefixed with the type hint is returned. If the type hint is invalid or the conversion
|
|
163
|
-
fails, an exception is raised.
|
|
162
|
+
Convert the internal value to the specified type and return its string representation
|
|
163
|
+
with the type hint prefix.
|
|
164
164
|
|
|
165
165
|
Parameters
|
|
166
166
|
----------
|
|
167
167
|
type_hint : str or EnvironmentValueType
|
|
168
|
-
The type
|
|
168
|
+
The type to which the internal value should be converted. Can be a string or an
|
|
169
|
+
EnvironmentValueType enum member. Must be one of the valid options in `OPTIONS`.
|
|
169
170
|
|
|
170
171
|
Returns
|
|
171
172
|
-------
|
|
172
173
|
Any
|
|
173
|
-
The string representation of the value with the type hint prefix, according to the
|
|
174
|
-
For example, "int:42", "list:[1, 2, 3]", etc.
|
|
174
|
+
The string representation of the value with the type hint prefix, according to the
|
|
175
|
+
specified type. For example, "int:42", "list:[1, 2, 3]", etc.
|
|
175
176
|
|
|
176
177
|
Raises
|
|
177
178
|
------
|
|
178
179
|
OrionisEnvironmentValueError
|
|
179
|
-
If the provided type hint is not valid or if the value cannot be converted to the
|
|
180
|
+
If the provided type hint is not valid or if the value cannot be converted to the
|
|
181
|
+
specified type.
|
|
180
182
|
"""
|
|
183
|
+
|
|
184
|
+
# Validate the type hint and ensure it is one of the defined options
|
|
181
185
|
try:
|
|
186
|
+
|
|
182
187
|
# If type_hint is an enum, convert it to its value string
|
|
183
188
|
if isinstance(type_hint, EnvironmentValueType):
|
|
184
189
|
type_hint = type_hint.value
|
|
@@ -195,26 +200,45 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
195
200
|
# Dispatch to the appropriate conversion method based on the type hint
|
|
196
201
|
if self.__type_hint == EnvironmentValueType.PATH.value:
|
|
197
202
|
return self.__toPath()
|
|
203
|
+
|
|
204
|
+
# If the type hint is 'str', convert to string
|
|
198
205
|
if self.__type_hint == EnvironmentValueType.STR.value:
|
|
199
206
|
return self.__toStr()
|
|
207
|
+
|
|
208
|
+
# If the type hint is 'int', convert to integer
|
|
200
209
|
if self.__type_hint == EnvironmentValueType.INT.value:
|
|
201
210
|
return self.__toInt()
|
|
211
|
+
|
|
212
|
+
# If the type hint is 'float', convert to float
|
|
202
213
|
if self.__type_hint == EnvironmentValueType.FLOAT.value:
|
|
203
214
|
return self.__toFloat()
|
|
215
|
+
|
|
216
|
+
# If the type hint is 'bool', convert to boolean
|
|
204
217
|
if self.__type_hint == EnvironmentValueType.BOOL.value:
|
|
205
218
|
return self.__toBool()
|
|
219
|
+
|
|
220
|
+
# If the type hint is 'list', convert to list
|
|
206
221
|
if self.__type_hint == EnvironmentValueType.LIST.value:
|
|
207
222
|
return self.__toList()
|
|
223
|
+
|
|
224
|
+
# If the type hint is 'dict', convert to dictionary
|
|
208
225
|
if self.__type_hint == EnvironmentValueType.DICT.value:
|
|
209
226
|
return self.__toDict()
|
|
227
|
+
|
|
228
|
+
# If the type hint is 'tuple', convert to tuple
|
|
210
229
|
if self.__type_hint == EnvironmentValueType.TUPLE.value:
|
|
211
230
|
return self.__toTuple()
|
|
231
|
+
|
|
232
|
+
# If the type hint is 'set', convert to set
|
|
212
233
|
if self.__type_hint == EnvironmentValueType.SET.value:
|
|
213
234
|
return self.__toSet()
|
|
235
|
+
|
|
236
|
+
# If the type hint is 'base64', convert to Base64 encoded string
|
|
214
237
|
if self.__type_hint == EnvironmentValueType.BASE64.value:
|
|
215
238
|
return self.__toBase64()
|
|
216
239
|
|
|
217
240
|
except OrionisEnvironmentValueError:
|
|
241
|
+
|
|
218
242
|
# Propagate specific type conversion errors
|
|
219
243
|
raise
|
|
220
244
|
|
|
@@ -226,16 +250,13 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
226
250
|
|
|
227
251
|
def __toBase64(self) -> str:
|
|
228
252
|
"""
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
This method checks if the internal value is a string or bytes. If so, it encodes the value in Base64
|
|
232
|
-
and returns a string in the format "<type_hint>:<base64_value>". If the internal value is not a string
|
|
233
|
-
or bytes, an exception is raised.
|
|
253
|
+
Convert the internal value to a Base64 encoded string with the type hint prefix.
|
|
234
254
|
|
|
235
255
|
Returns
|
|
236
256
|
-------
|
|
237
257
|
str
|
|
238
|
-
A
|
|
258
|
+
A string in the format "<type_hint>:<base64_value>", where <base64_value> is the Base64
|
|
259
|
+
encoded representation of the internal value.
|
|
239
260
|
|
|
240
261
|
Raises
|
|
241
262
|
------
|
|
@@ -244,6 +265,7 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
244
265
|
"""
|
|
245
266
|
import base64
|
|
246
267
|
|
|
268
|
+
# Ensure the internal value is a string or bytes before encoding
|
|
247
269
|
if not isinstance(self.__value_raw, (str, bytes)):
|
|
248
270
|
raise OrionisEnvironmentValueError(
|
|
249
271
|
f"Value must be a string or bytes to convert to Base64, got {type(self.__value_raw).__name__} instead."
|
|
@@ -257,46 +279,43 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
257
279
|
|
|
258
280
|
def __parseBase64(self) -> str:
|
|
259
281
|
"""
|
|
260
|
-
|
|
282
|
+
Decode the internal raw value from Base64 encoding.
|
|
261
283
|
|
|
262
|
-
|
|
263
|
-
If
|
|
284
|
+
Decodes the Base64-encoded string stored in the internal raw value and returns the decoded result as a string.
|
|
285
|
+
If decoding fails, raises an OrionisEnvironmentValueException.
|
|
264
286
|
|
|
265
287
|
Returns
|
|
266
288
|
-------
|
|
267
289
|
str
|
|
268
|
-
The decoded
|
|
290
|
+
The decoded string from the Base64-encoded internal value.
|
|
269
291
|
|
|
270
292
|
Raises
|
|
271
293
|
------
|
|
272
294
|
OrionisEnvironmentValueException
|
|
273
|
-
If the value cannot be decoded from Base64.
|
|
295
|
+
If the internal value cannot be decoded from Base64.
|
|
274
296
|
"""
|
|
275
297
|
import base64
|
|
276
298
|
|
|
277
299
|
try:
|
|
278
|
-
# Decode the Base64 encoded value
|
|
300
|
+
# Decode the Base64 encoded value and return as string
|
|
279
301
|
decoded_value = base64.b64decode(self.__value_raw).decode()
|
|
280
302
|
return decoded_value
|
|
281
303
|
except Exception as e:
|
|
304
|
+
# Raise a custom exception if decoding fails
|
|
282
305
|
raise OrionisEnvironmentValueException(f"Cannot decode Base64 value '{self.__value_raw}': {str(e)}")
|
|
283
306
|
|
|
284
307
|
def __parsePath(self):
|
|
285
308
|
"""
|
|
286
|
-
|
|
309
|
+
Convert the internal raw value to a normalized POSIX path string.
|
|
287
310
|
|
|
288
|
-
This method processes the internal value as a file system path.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
Parameters
|
|
292
|
-
----------
|
|
293
|
-
self : EnvironmentCaster
|
|
294
|
-
The instance of the EnvironmentCaster class.
|
|
311
|
+
This method processes the internal value as a file system path. If the value is already
|
|
312
|
+
a `Path` object, it returns its POSIX representation. If the value is a string, it replaces
|
|
313
|
+
backslashes with forward slashes for normalization and returns the POSIX path string.
|
|
295
314
|
|
|
296
315
|
Returns
|
|
297
316
|
-------
|
|
298
|
-
|
|
299
|
-
|
|
317
|
+
str
|
|
318
|
+
The normalized POSIX path string representing the file system path.
|
|
300
319
|
|
|
301
320
|
Raises
|
|
302
321
|
------
|
|
@@ -305,121 +324,116 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
305
324
|
"""
|
|
306
325
|
from pathlib import Path
|
|
307
326
|
|
|
308
|
-
# If the value is already a Path object, return
|
|
327
|
+
# If the value is already a Path object, return its POSIX representation
|
|
309
328
|
if isinstance(self.__value_raw, Path):
|
|
310
329
|
return self.__value_raw.as_posix()
|
|
311
330
|
|
|
312
331
|
# Normalize the path by replacing backslashes with forward slashes
|
|
313
332
|
normalized_path = str(self.__value_raw).replace('\\', '/')
|
|
314
333
|
|
|
315
|
-
#
|
|
334
|
+
# Convert the normalized string to a Path object and return its POSIX representation
|
|
316
335
|
return Path(normalized_path).as_posix()
|
|
317
336
|
|
|
318
337
|
def __toPath(self) -> str:
|
|
319
338
|
"""
|
|
320
|
-
|
|
339
|
+
Convert the internal value to an absolute POSIX path string with type hint prefix.
|
|
321
340
|
|
|
322
341
|
Returns
|
|
323
342
|
-------
|
|
324
343
|
str
|
|
325
|
-
A string
|
|
344
|
+
A string in the format "<type_hint>:<absolute_path>", where <absolute_path> is the
|
|
345
|
+
normalized, absolute POSIX path representation of the internal value.
|
|
326
346
|
|
|
327
347
|
Raises
|
|
328
348
|
------
|
|
329
349
|
OrionisEnvironmentValueError
|
|
330
|
-
If the internal value is not a string or Path.
|
|
350
|
+
If the internal value is not a string or a pathlib.Path object.
|
|
331
351
|
"""
|
|
332
352
|
from pathlib import Path
|
|
333
353
|
import os
|
|
334
354
|
|
|
355
|
+
# Ensure the internal value is a string or Path object
|
|
335
356
|
if not isinstance(self.__value_raw, (str, Path)):
|
|
336
357
|
raise OrionisEnvironmentValueError(
|
|
337
|
-
|
|
358
|
+
f"Value must be a string or Path to convert to path, got {type(self.__value_raw).__name__} instead."
|
|
338
359
|
)
|
|
339
360
|
|
|
340
|
-
# Normalize slashes and strip whitespace
|
|
361
|
+
# Normalize slashes and strip whitespace from the path string
|
|
341
362
|
raw_path = str(self.__value_raw).replace('\\', '/').strip()
|
|
342
363
|
|
|
343
|
-
#
|
|
364
|
+
# Create a Path object from the normalized path string
|
|
344
365
|
path_obj = Path(raw_path)
|
|
345
366
|
|
|
346
|
-
# If the path is not absolute,
|
|
367
|
+
# If the path is not absolute, resolve it relative to the current working directory
|
|
347
368
|
if not path_obj.is_absolute():
|
|
348
369
|
|
|
349
|
-
# Remove leading slash
|
|
370
|
+
# Remove any leading slash to avoid creating an absolute path when joining
|
|
350
371
|
raw_path_no_leading = raw_path.lstrip('/\\')
|
|
372
|
+
|
|
373
|
+
# Combine with the current working directory to form an absolute path
|
|
351
374
|
path_obj = Path(Path.cwd()) / raw_path_no_leading
|
|
352
375
|
|
|
353
|
-
#
|
|
376
|
+
# Expand user home and convert to POSIX format for consistency
|
|
354
377
|
abs_path = path_obj.expanduser().as_posix()
|
|
355
378
|
|
|
356
|
-
# Return the absolute path as a string with the type hint
|
|
379
|
+
# Return the absolute path as a string with the type hint prefix
|
|
357
380
|
return f"{self.__type_hint}:{str(abs_path)}"
|
|
358
381
|
|
|
359
382
|
def __parseStr(self):
|
|
360
383
|
"""
|
|
361
|
-
Returns the value as a string,
|
|
384
|
+
Returns the internal raw value as a string, removing leading whitespace.
|
|
362
385
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
386
|
+
Parameters
|
|
387
|
+
----------
|
|
388
|
+
self : EnvironmentCaster
|
|
389
|
+
Instance of the EnvironmentCaster class.
|
|
367
390
|
|
|
368
391
|
Returns
|
|
369
392
|
-------
|
|
370
393
|
str
|
|
371
394
|
The internal value as a string with leading whitespace removed.
|
|
372
395
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
396
|
+
Notes
|
|
397
|
+
-----
|
|
398
|
+
No type conversion is performed; the value is returned as a string after
|
|
399
|
+
stripping leading whitespace. This method assumes the type hint is 'str:'.
|
|
400
|
+
No exceptions are raised by this method.
|
|
377
401
|
"""
|
|
378
402
|
|
|
379
|
-
#
|
|
403
|
+
# Remove leading whitespace from the internal value
|
|
404
|
+
# This ensures that any accidental spaces before the value are ignored
|
|
380
405
|
return self.__value_raw.lstrip()
|
|
381
406
|
|
|
382
407
|
def __toStr(self):
|
|
383
408
|
"""
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
This method checks if the internal value is a string. If so, it returns a string
|
|
387
|
-
in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
388
|
-
and <value> is the internal string value. If the internal value is not a string,
|
|
389
|
-
an exception is raised.
|
|
409
|
+
Returns the internal value as a string representation with the type hint prefix.
|
|
390
410
|
|
|
391
411
|
Returns
|
|
392
412
|
-------
|
|
393
413
|
str
|
|
394
|
-
|
|
414
|
+
The string representation of the internal value, prefixed by the type hint and separated by a colon.
|
|
395
415
|
|
|
396
416
|
Raises
|
|
397
417
|
------
|
|
398
418
|
OrionisEnvironmentValueError
|
|
399
419
|
If the internal value is not a string.
|
|
400
420
|
"""
|
|
401
|
-
|
|
402
421
|
# Ensure the internal value is a string before conversion
|
|
403
422
|
if not isinstance(self.__value_raw, str):
|
|
423
|
+
# Raise an error if the value is not a string
|
|
404
424
|
raise OrionisEnvironmentValueError(
|
|
405
425
|
f"Value must be a string to convert to str, got {type(self.__value_raw).__name__} instead."
|
|
406
426
|
)
|
|
407
427
|
|
|
408
428
|
# Return the formatted string with type hint and value
|
|
409
|
-
return f"{self.__value_raw}"
|
|
429
|
+
return f"{self.__type_hint}:{self.__value_raw}"
|
|
410
430
|
|
|
411
431
|
def __parseInt(self):
|
|
412
432
|
"""
|
|
413
|
-
|
|
433
|
+
Convert the internal raw value to an integer.
|
|
414
434
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
format or non-integer input, an `OrionisEnvironmentValueException` is raised.
|
|
418
|
-
|
|
419
|
-
Parameters
|
|
420
|
-
----------
|
|
421
|
-
self : EnvironmentCaster
|
|
422
|
-
The instance of the EnvironmentCaster class.
|
|
435
|
+
Strips leading and trailing whitespace from the internal raw value and attempts to convert it to an integer.
|
|
436
|
+
Raises an OrionisEnvironmentValueException if the conversion fails due to invalid format or type.
|
|
423
437
|
|
|
424
438
|
Returns
|
|
425
439
|
-------
|
|
@@ -437,7 +451,6 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
437
451
|
# Attempt to convert the value to an integer
|
|
438
452
|
try:
|
|
439
453
|
return int(value)
|
|
440
|
-
|
|
441
454
|
# Raise a custom exception if conversion fails
|
|
442
455
|
except ValueError as e:
|
|
443
456
|
raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to int: {str(e)}")
|
|
@@ -446,14 +459,11 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
446
459
|
"""
|
|
447
460
|
Converts the internal value to a string representation with the integer type hint prefix.
|
|
448
461
|
|
|
449
|
-
This method checks if the internal value is an integer. If so, it returns a string
|
|
450
|
-
in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
451
|
-
and <value> is the integer value. If the internal value is not an integer, an exception is raised.
|
|
452
|
-
|
|
453
462
|
Returns
|
|
454
463
|
-------
|
|
455
464
|
str
|
|
456
|
-
|
|
465
|
+
String in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
466
|
+
and <value> is the integer value.
|
|
457
467
|
|
|
458
468
|
Raises
|
|
459
469
|
------
|
|
@@ -461,8 +471,10 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
461
471
|
If the internal value is not an integer.
|
|
462
472
|
"""
|
|
463
473
|
|
|
464
|
-
#
|
|
474
|
+
# Check if the internal value is an integer before conversion
|
|
465
475
|
if not isinstance(self.__value_raw, int):
|
|
476
|
+
|
|
477
|
+
# Raise an error if the value is not an integer
|
|
466
478
|
raise OrionisEnvironmentValueError(
|
|
467
479
|
f"Value must be an integer to convert to int, got {type(self.__value_raw).__name__} instead."
|
|
468
480
|
)
|
|
@@ -472,16 +484,10 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
472
484
|
|
|
473
485
|
def __parseFloat(self):
|
|
474
486
|
"""
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
This method attempts to strip leading and trailing whitespace from the internal
|
|
478
|
-
raw value and convert it to a float. If the conversion fails due to an invalid
|
|
479
|
-
format or non-numeric input, an `OrionisEnvironmentValueException` is raised.
|
|
487
|
+
Convert the internal raw value to a float.
|
|
480
488
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
self : EnvironmentCaster
|
|
484
|
-
The instance of the EnvironmentCaster class.
|
|
489
|
+
Strips leading and trailing whitespace from the internal raw value and attempts to convert it to a float.
|
|
490
|
+
Raises an OrionisEnvironmentValueException if the conversion fails due to invalid format or type.
|
|
485
491
|
|
|
486
492
|
Returns
|
|
487
493
|
-------
|
|
@@ -493,7 +499,8 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
493
499
|
OrionisEnvironmentValueException
|
|
494
500
|
If the value cannot be converted to a float due to invalid format or type.
|
|
495
501
|
"""
|
|
496
|
-
|
|
502
|
+
|
|
503
|
+
# Remove leading and trailing whitespace from the raw value to ensure clean input
|
|
497
504
|
value = self.__value_raw.strip()
|
|
498
505
|
|
|
499
506
|
# Attempt to convert the value to a float
|
|
@@ -508,24 +515,21 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
508
515
|
"""
|
|
509
516
|
Converts the internal value to a string representation with the float type hint prefix.
|
|
510
517
|
|
|
511
|
-
This method checks if the internal value is a float. If so, it returns a string
|
|
512
|
-
in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
513
|
-
and <value> is the float value. If the internal value is not a float, an exception is raised.
|
|
514
|
-
|
|
515
518
|
Returns
|
|
516
519
|
-------
|
|
517
520
|
str
|
|
518
|
-
A string
|
|
519
|
-
|
|
521
|
+
A string in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
522
|
+
and <value> is the float value.
|
|
520
523
|
|
|
521
524
|
Raises
|
|
522
525
|
------
|
|
523
526
|
OrionisEnvironmentValueError
|
|
524
527
|
If the internal value is not a float.
|
|
525
528
|
"""
|
|
526
|
-
|
|
527
529
|
# Ensure the internal value is a float before conversion
|
|
528
530
|
if not isinstance(self.__value_raw, float):
|
|
531
|
+
|
|
532
|
+
# Raise an error if the value is not a float
|
|
529
533
|
raise OrionisEnvironmentValueError(
|
|
530
534
|
f"Value must be a float to convert to float, got {type(self.__value_raw).__name__} instead."
|
|
531
535
|
)
|
|
@@ -535,59 +539,47 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
535
539
|
|
|
536
540
|
def __parseBool(self):
|
|
537
541
|
"""
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
This method processes the internal raw value by stripping leading and trailing whitespace,
|
|
541
|
-
converting it to lowercase, and then checking if it matches the string 'true' or 'false'.
|
|
542
|
-
If the value is 'true', it returns the boolean value True. If the value is 'false', it returns
|
|
543
|
-
the boolean value False. If the value does not match either, an `OrionisEnvironmentValueException`
|
|
544
|
-
is raised.
|
|
542
|
+
Convert the internal raw value to a boolean.
|
|
545
543
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
544
|
+
This method strips leading and trailing whitespace from the internal raw value,
|
|
545
|
+
converts it to lowercase, and checks if it matches 'true' or 'false'. If the value
|
|
546
|
+
is 'true', it returns True. If the value is 'false', it returns False. If the value
|
|
547
|
+
does not match either, an OrionisEnvironmentValueException is raised.
|
|
550
548
|
|
|
551
549
|
Returns
|
|
552
550
|
-------
|
|
553
551
|
bool
|
|
554
|
-
|
|
552
|
+
True if the value is 'true' (case-insensitive), False if the value is 'false' (case-insensitive).
|
|
555
553
|
|
|
556
554
|
Raises
|
|
557
555
|
------
|
|
558
556
|
OrionisEnvironmentValueException
|
|
559
557
|
If the value cannot be converted to a boolean because it does not match 'true' or 'false'.
|
|
560
558
|
"""
|
|
561
|
-
|
|
562
|
-
# Strip whitespace and convert the value to lowercase for comparison
|
|
559
|
+
# Remove leading and trailing whitespace, then convert to lowercase for comparison
|
|
563
560
|
value = self.__value_raw.strip().lower()
|
|
564
561
|
|
|
565
|
-
#
|
|
562
|
+
# If the value is 'true', return True
|
|
566
563
|
if value == 'true':
|
|
567
564
|
return True
|
|
568
565
|
|
|
569
|
-
#
|
|
566
|
+
# If the value is 'false', return False
|
|
570
567
|
elif value == 'false':
|
|
571
568
|
return False
|
|
572
569
|
|
|
573
|
-
#
|
|
570
|
+
# If the value is neither 'true' nor 'false', raise an exception
|
|
574
571
|
else:
|
|
575
572
|
raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to bool.")
|
|
576
573
|
|
|
577
574
|
def __toBool(self):
|
|
578
575
|
"""
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
This method checks if the internal value is a boolean. If so, it returns a string
|
|
582
|
-
in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
583
|
-
and <value> is the lowercase string representation of the boolean value.
|
|
584
|
-
If the internal value is not a boolean, an exception is raised.
|
|
576
|
+
Convert the internal value to a string representation with the boolean type hint prefix.
|
|
585
577
|
|
|
586
578
|
Returns
|
|
587
579
|
-------
|
|
588
580
|
str
|
|
589
|
-
A string
|
|
590
|
-
|
|
581
|
+
A string in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
582
|
+
and <value> is the lowercase string representation of the boolean value ('true' or 'false').
|
|
591
583
|
|
|
592
584
|
Raises
|
|
593
585
|
------
|
|
@@ -597,6 +589,8 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
597
589
|
|
|
598
590
|
# Ensure the internal value is a boolean before conversion
|
|
599
591
|
if not isinstance(self.__value_raw, bool):
|
|
592
|
+
|
|
593
|
+
# Raise an error if the value is not a boolean
|
|
600
594
|
raise OrionisEnvironmentValueError(
|
|
601
595
|
f"Value must be a boolean to convert to bool, got {type(self.__value_raw).__name__} instead."
|
|
602
596
|
)
|
|
@@ -606,22 +600,18 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
606
600
|
|
|
607
601
|
def __parseList(self):
|
|
608
602
|
"""
|
|
609
|
-
|
|
603
|
+
Parses the internal raw value and converts it to a Python list.
|
|
610
604
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
605
|
+
The method strips leading and trailing whitespace from the internal raw value,
|
|
606
|
+
then attempts to safely evaluate the string as a Python list using `ast.literal_eval`.
|
|
607
|
+
If the conversion is successful and the result is a list, it is returned.
|
|
608
|
+
If the conversion fails or the evaluated value is not a list, an
|
|
614
609
|
`OrionisEnvironmentValueException` is raised.
|
|
615
610
|
|
|
616
|
-
Parameters
|
|
617
|
-
----------
|
|
618
|
-
self : EnvironmentCaster
|
|
619
|
-
The instance of the EnvironmentCaster class.
|
|
620
|
-
|
|
621
611
|
Returns
|
|
622
612
|
-------
|
|
623
613
|
list
|
|
624
|
-
The internal value converted to a list
|
|
614
|
+
The internal value converted to a list.
|
|
625
615
|
|
|
626
616
|
Raises
|
|
627
617
|
------
|
|
@@ -630,19 +620,19 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
630
620
|
"""
|
|
631
621
|
import ast
|
|
632
622
|
|
|
633
|
-
# Remove leading and trailing whitespace from the raw value
|
|
623
|
+
# Remove leading and trailing whitespace from the raw value to ensure clean input
|
|
634
624
|
value = self.__value_raw.strip()
|
|
635
625
|
|
|
636
626
|
try:
|
|
637
627
|
|
|
638
|
-
# Safely evaluate the string to a Python object
|
|
628
|
+
# Safely evaluate the string to a Python object using ast.literal_eval
|
|
639
629
|
parsed = ast.literal_eval(value)
|
|
640
630
|
|
|
641
631
|
# Ensure the evaluated object is a list
|
|
642
632
|
if not isinstance(parsed, list):
|
|
643
633
|
raise ValueError("Value is not a list")
|
|
644
634
|
|
|
645
|
-
# Return the parsed list
|
|
635
|
+
# Return the parsed list if successful
|
|
646
636
|
return parsed
|
|
647
637
|
|
|
648
638
|
except (ValueError, SyntaxError) as e:
|
|
@@ -652,18 +642,18 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
652
642
|
|
|
653
643
|
def __toList(self):
|
|
654
644
|
"""
|
|
655
|
-
Converts the internal value to
|
|
645
|
+
Converts the internal value to its string representation with the list type hint prefix.
|
|
656
646
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
647
|
+
Parameters
|
|
648
|
+
----------
|
|
649
|
+
self : EnvironmentCaster
|
|
650
|
+
Instance of the EnvironmentCaster class.
|
|
661
651
|
|
|
662
652
|
Returns
|
|
663
653
|
-------
|
|
664
654
|
str
|
|
665
|
-
A string
|
|
666
|
-
|
|
655
|
+
A string in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
656
|
+
and <value> is the string representation of the list.
|
|
667
657
|
|
|
668
658
|
Raises
|
|
669
659
|
------
|
|
@@ -673,8 +663,10 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
673
663
|
|
|
674
664
|
# Ensure the internal value is a list before conversion
|
|
675
665
|
if not isinstance(self.__value_raw, list):
|
|
666
|
+
|
|
667
|
+
# Raise an error if the value is not a list
|
|
676
668
|
raise OrionisEnvironmentValueError(
|
|
677
|
-
|
|
669
|
+
f"Value must be a list to convert to list, got {type(self.__value_raw).__name__} instead."
|
|
678
670
|
)
|
|
679
671
|
|
|
680
672
|
# Return the formatted string with type hint and list value
|
|
@@ -682,22 +674,18 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
682
674
|
|
|
683
675
|
def __parseDict(self):
|
|
684
676
|
"""
|
|
685
|
-
|
|
677
|
+
Parses the internal raw value and converts it to a Python dictionary.
|
|
686
678
|
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
If the conversion
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
Parameters
|
|
693
|
-
----------
|
|
694
|
-
self : EnvironmentCaster
|
|
695
|
-
The instance of the EnvironmentCaster class.
|
|
679
|
+
The method strips leading and trailing whitespace from the internal raw value,
|
|
680
|
+
then attempts to safely evaluate the string as a Python dictionary using
|
|
681
|
+
`ast.literal_eval`. If the conversion is successful and the result is a dictionary,
|
|
682
|
+
it is returned. If the conversion fails or the evaluated value is not a dictionary,
|
|
683
|
+
an OrionisEnvironmentValueException is raised.
|
|
696
684
|
|
|
697
685
|
Returns
|
|
698
686
|
-------
|
|
699
687
|
dict
|
|
700
|
-
The internal value converted to a dictionary
|
|
688
|
+
The internal value converted to a dictionary.
|
|
701
689
|
|
|
702
690
|
Raises
|
|
703
691
|
------
|
|
@@ -706,19 +694,19 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
706
694
|
"""
|
|
707
695
|
import ast
|
|
708
696
|
|
|
709
|
-
# Remove leading and trailing whitespace from the raw value
|
|
697
|
+
# Remove leading and trailing whitespace from the raw value to ensure clean input
|
|
710
698
|
value = self.__value_raw.strip()
|
|
711
699
|
|
|
712
700
|
try:
|
|
713
701
|
|
|
714
|
-
# Safely evaluate the string to a Python object
|
|
702
|
+
# Safely evaluate the string to a Python object using ast.literal_eval
|
|
715
703
|
parsed = ast.literal_eval(value)
|
|
716
704
|
|
|
717
705
|
# Ensure the evaluated object is a dictionary
|
|
718
706
|
if not isinstance(parsed, dict):
|
|
719
707
|
raise ValueError("Value is not a dict")
|
|
720
708
|
|
|
721
|
-
# Return the parsed dictionary
|
|
709
|
+
# Return the parsed dictionary if successful
|
|
722
710
|
return parsed
|
|
723
711
|
|
|
724
712
|
except (ValueError, SyntaxError) as e:
|
|
@@ -730,25 +718,21 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
730
718
|
"""
|
|
731
719
|
Converts the internal value to a string representation with the dictionary type hint prefix.
|
|
732
720
|
|
|
733
|
-
This method checks if the internal value is a dictionary. If so, it returns a string
|
|
734
|
-
in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
735
|
-
and <value> is the string representation of the dictionary. If the internal value is not a dictionary,
|
|
736
|
-
an exception is raised.
|
|
737
|
-
|
|
738
721
|
Returns
|
|
739
722
|
-------
|
|
740
723
|
str
|
|
741
|
-
A string
|
|
742
|
-
|
|
724
|
+
A string in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
725
|
+
and <value> is the string representation of the dictionary.
|
|
743
726
|
|
|
744
727
|
Raises
|
|
745
728
|
------
|
|
746
729
|
OrionisEnvironmentValueError
|
|
747
730
|
If the internal value is not a dictionary.
|
|
748
731
|
"""
|
|
749
|
-
|
|
750
732
|
# Ensure the internal value is a dictionary before conversion
|
|
751
733
|
if not isinstance(self.__value_raw, dict):
|
|
734
|
+
|
|
735
|
+
# Raise an error if the value is not a dictionary
|
|
752
736
|
raise OrionisEnvironmentValueError(
|
|
753
737
|
f"Value must be a dict to convert to dict, got {type(self.__value_raw).__name__} instead."
|
|
754
738
|
)
|
|
@@ -758,23 +742,18 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
758
742
|
|
|
759
743
|
def __parseTuple(self):
|
|
760
744
|
"""
|
|
761
|
-
|
|
745
|
+
Parse the internal raw value and convert it to a Python tuple.
|
|
762
746
|
|
|
763
|
-
|
|
747
|
+
The method removes leading and trailing whitespace from the internal raw value,
|
|
764
748
|
then attempts to safely evaluate the string as a Python tuple using `ast.literal_eval`.
|
|
765
749
|
If the conversion is successful and the result is a tuple, it is returned.
|
|
766
750
|
If the conversion fails or the evaluated value is not a tuple, an
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
Parameters
|
|
770
|
-
----------
|
|
771
|
-
self : EnvironmentCaster
|
|
772
|
-
The instance of the EnvironmentCaster class.
|
|
751
|
+
OrionisEnvironmentValueException is raised.
|
|
773
752
|
|
|
774
753
|
Returns
|
|
775
754
|
-------
|
|
776
755
|
tuple
|
|
777
|
-
The internal value converted to a tuple
|
|
756
|
+
The internal value converted to a tuple.
|
|
778
757
|
|
|
779
758
|
Raises
|
|
780
759
|
------
|
|
@@ -783,19 +762,19 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
783
762
|
"""
|
|
784
763
|
import ast
|
|
785
764
|
|
|
786
|
-
# Remove leading and trailing whitespace from the raw value
|
|
765
|
+
# Remove leading and trailing whitespace from the raw value to ensure clean input
|
|
787
766
|
value = self.__value_raw.strip()
|
|
788
767
|
|
|
789
768
|
try:
|
|
790
769
|
|
|
791
|
-
# Safely evaluate the string to a Python object
|
|
770
|
+
# Safely evaluate the string to a Python object using ast.literal_eval
|
|
792
771
|
parsed = ast.literal_eval(value)
|
|
793
772
|
|
|
794
773
|
# Ensure the evaluated object is a tuple
|
|
795
774
|
if not isinstance(parsed, tuple):
|
|
796
775
|
raise ValueError("Value is not a tuple")
|
|
797
776
|
|
|
798
|
-
# Return the parsed tuple
|
|
777
|
+
# Return the parsed tuple if successful
|
|
799
778
|
return parsed
|
|
800
779
|
|
|
801
780
|
except (ValueError, SyntaxError) as e:
|
|
@@ -805,18 +784,13 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
805
784
|
|
|
806
785
|
def __toTuple(self):
|
|
807
786
|
"""
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
This method checks if the internal value is a tuple. If so, it returns a string
|
|
811
|
-
in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
812
|
-
and <value> is the string representation of the tuple. If the internal value is not a tuple,
|
|
813
|
-
an exception is raised.
|
|
787
|
+
Convert the internal value to a string representation with the tuple type hint prefix.
|
|
814
788
|
|
|
815
789
|
Returns
|
|
816
790
|
-------
|
|
817
791
|
str
|
|
818
|
-
A string
|
|
819
|
-
|
|
792
|
+
A string in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
793
|
+
and <value> is the string representation of the tuple.
|
|
820
794
|
|
|
821
795
|
Raises
|
|
822
796
|
------
|
|
@@ -826,6 +800,8 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
826
800
|
|
|
827
801
|
# Ensure the internal value is a tuple before conversion
|
|
828
802
|
if not isinstance(self.__value_raw, tuple):
|
|
803
|
+
|
|
804
|
+
# Raise an error if the value is not a tuple
|
|
829
805
|
raise OrionisEnvironmentValueError(
|
|
830
806
|
f"Value must be a tuple to convert to tuple, got {type(self.__value_raw).__name__} instead."
|
|
831
807
|
)
|
|
@@ -835,18 +811,18 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
835
811
|
|
|
836
812
|
def __parseSet(self):
|
|
837
813
|
"""
|
|
838
|
-
|
|
814
|
+
Parse the internal raw value and convert it to a Python set.
|
|
839
815
|
|
|
840
|
-
This method
|
|
816
|
+
This method removes leading and trailing whitespace from the internal raw value,
|
|
841
817
|
then attempts to safely evaluate the string as a Python set using `ast.literal_eval`.
|
|
842
818
|
If the conversion is successful and the result is a set, it is returned.
|
|
843
819
|
If the conversion fails or the evaluated value is not a set, an
|
|
844
|
-
|
|
820
|
+
OrionisEnvironmentValueException is raised.
|
|
845
821
|
|
|
846
822
|
Returns
|
|
847
823
|
-------
|
|
848
824
|
set
|
|
849
|
-
The internal value converted to a set
|
|
825
|
+
The internal value converted to a set.
|
|
850
826
|
|
|
851
827
|
Raises
|
|
852
828
|
------
|
|
@@ -855,19 +831,19 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
855
831
|
"""
|
|
856
832
|
import ast
|
|
857
833
|
|
|
858
|
-
# Remove leading and trailing whitespace from the raw value
|
|
834
|
+
# Remove leading and trailing whitespace from the raw value to ensure clean input
|
|
859
835
|
value = self.__value_raw.strip()
|
|
860
836
|
|
|
861
837
|
try:
|
|
862
838
|
|
|
863
|
-
# Safely evaluate the string to a Python object
|
|
839
|
+
# Safely evaluate the string to a Python object using ast.literal_eval
|
|
864
840
|
parsed = ast.literal_eval(value)
|
|
865
841
|
|
|
866
842
|
# Ensure the evaluated object is a set
|
|
867
843
|
if not isinstance(parsed, set):
|
|
868
844
|
raise ValueError("Value is not a set")
|
|
869
845
|
|
|
870
|
-
# Return the parsed set
|
|
846
|
+
# Return the parsed set if successful
|
|
871
847
|
return parsed
|
|
872
848
|
|
|
873
849
|
except (ValueError, SyntaxError) as e:
|
|
@@ -877,29 +853,24 @@ class EnvironmentCaster(IEnvironmentCaster):
|
|
|
877
853
|
|
|
878
854
|
def __toSet(self):
|
|
879
855
|
"""
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
This method checks if the internal value is a set. If so, it returns a string
|
|
883
|
-
in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
884
|
-
and <value> is the string representation of the set. If the internal value is not a set,
|
|
885
|
-
an exception is raised.
|
|
856
|
+
Convert the internal value to a string representation with the set type hint prefix.
|
|
886
857
|
|
|
887
858
|
Returns
|
|
888
859
|
-------
|
|
889
860
|
str
|
|
890
|
-
A string
|
|
891
|
-
|
|
861
|
+
A string in the format "<type_hint>:<value>", where <type_hint> is the current type hint
|
|
862
|
+
and <value> is the string representation of the set.
|
|
892
863
|
|
|
893
864
|
Raises
|
|
894
865
|
------
|
|
895
866
|
OrionisEnvironmentValueError
|
|
896
867
|
If the internal value is not a set.
|
|
897
868
|
"""
|
|
898
|
-
|
|
899
869
|
# Ensure the internal value is a set before conversion
|
|
900
870
|
if not isinstance(self.__value_raw, set):
|
|
871
|
+
# Raise an error if the value is not a set
|
|
901
872
|
raise OrionisEnvironmentValueError(
|
|
902
|
-
|
|
873
|
+
f"Value must be a set to convert to set, got {type(self.__value_raw).__name__} instead."
|
|
903
874
|
)
|
|
904
875
|
|
|
905
876
|
# Return the formatted string with type hint and set value
|