librelane 3.0.0.dev40__py3-none-any.whl → 3.0.0.dev41__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.
Potentially problematic release.
This version of librelane might be problematic. Click here for more details.
- librelane/config/variable.py +20 -10
- {librelane-3.0.0.dev40.dist-info → librelane-3.0.0.dev41.dist-info}/METADATA +1 -1
- {librelane-3.0.0.dev40.dist-info → librelane-3.0.0.dev41.dist-info}/RECORD +5 -5
- {librelane-3.0.0.dev40.dist-info → librelane-3.0.0.dev41.dist-info}/WHEEL +0 -0
- {librelane-3.0.0.dev40.dist-info → librelane-3.0.0.dev41.dist-info}/entry_points.txt +0 -0
librelane/config/variable.py
CHANGED
|
@@ -16,7 +16,6 @@ import inspect
|
|
|
16
16
|
from enum import Enum
|
|
17
17
|
from decimal import Decimal, InvalidOperation
|
|
18
18
|
from dataclasses import (
|
|
19
|
-
_MISSING_TYPE,
|
|
20
19
|
MISSING,
|
|
21
20
|
asdict,
|
|
22
21
|
dataclass,
|
|
@@ -24,6 +23,7 @@ from dataclasses import (
|
|
|
24
23
|
fields,
|
|
25
24
|
is_dataclass,
|
|
26
25
|
)
|
|
26
|
+
import types
|
|
27
27
|
from typing import (
|
|
28
28
|
ClassVar,
|
|
29
29
|
Dict,
|
|
@@ -219,7 +219,8 @@ class Macro:
|
|
|
219
219
|
|
|
220
220
|
def is_optional(t: Type[Any]) -> bool:
|
|
221
221
|
type_args = get_args(t)
|
|
222
|
-
|
|
222
|
+
origin = get_origin(t)
|
|
223
|
+
return (origin is Union or origin is types.UnionType) and type(None) in type_args
|
|
223
224
|
|
|
224
225
|
|
|
225
226
|
def some_of(t: Type[Any]) -> Type[Any]:
|
|
@@ -229,11 +230,20 @@ def some_of(t: Type[Any]) -> Type[Any]:
|
|
|
229
230
|
# t must be a Union with None if we're here
|
|
230
231
|
|
|
231
232
|
type_args = get_args(t)
|
|
233
|
+
origin = get_origin(t)
|
|
232
234
|
|
|
233
|
-
args_without_none = [arg for arg in type_args if arg
|
|
235
|
+
args_without_none = [arg for arg in type_args if arg is not type(None)]
|
|
234
236
|
if len(args_without_none) == 1:
|
|
235
237
|
return args_without_none[0]
|
|
236
238
|
|
|
239
|
+
if origin is types.UnionType:
|
|
240
|
+
# Use the | operator to create a UnionType
|
|
241
|
+
result = args_without_none[0]
|
|
242
|
+
for arg in args_without_none[1:]:
|
|
243
|
+
result = result | arg
|
|
244
|
+
return result
|
|
245
|
+
|
|
246
|
+
# Otherwise, return a typing.Union
|
|
237
247
|
new_union = Union[tuple(args_without_none)] # type: ignore
|
|
238
248
|
return new_union # type: ignore
|
|
239
249
|
|
|
@@ -440,7 +450,7 @@ class Variable:
|
|
|
440
450
|
return_value = list()
|
|
441
451
|
raw = value
|
|
442
452
|
if isinstance(raw, list) or isinstance(raw, tuple):
|
|
443
|
-
if type_origin
|
|
453
|
+
if type_origin is list and type_args == (str,):
|
|
444
454
|
if any(isinstance(item, List) for item in raw):
|
|
445
455
|
Variable.__flatten_list(value)
|
|
446
456
|
pass
|
|
@@ -462,7 +472,7 @@ class Variable:
|
|
|
462
472
|
f"List provided for variable '{key_path}' is invalid: {value}"
|
|
463
473
|
)
|
|
464
474
|
|
|
465
|
-
if type_origin
|
|
475
|
+
if type_origin is tuple:
|
|
466
476
|
if len(raw) != len(type_args):
|
|
467
477
|
raise ValueError(
|
|
468
478
|
f"Value provided for variable '{key_path}' of type {validating_type} is invalid: ({len(raw)}/{len(type_args)}) tuple entries provided"
|
|
@@ -481,11 +491,11 @@ class Variable:
|
|
|
481
491
|
)
|
|
482
492
|
)
|
|
483
493
|
|
|
484
|
-
if type_origin
|
|
494
|
+
if type_origin is tuple:
|
|
485
495
|
return tuple(return_value)
|
|
486
496
|
|
|
487
497
|
return return_value
|
|
488
|
-
elif type_origin
|
|
498
|
+
elif type_origin is dict:
|
|
489
499
|
raw = value
|
|
490
500
|
key_type, value_type = type_args
|
|
491
501
|
if isinstance(raw, dict):
|
|
@@ -586,7 +596,7 @@ class Variable:
|
|
|
586
596
|
field_default = None
|
|
587
597
|
if (
|
|
588
598
|
current_field.default is not None
|
|
589
|
-
and
|
|
599
|
+
and current_field.default != MISSING
|
|
590
600
|
):
|
|
591
601
|
field_default = current_field.default
|
|
592
602
|
if current_field.default_factory != MISSING:
|
|
@@ -615,7 +625,7 @@ class Variable:
|
|
|
615
625
|
result = Path(value)
|
|
616
626
|
result.validate(f"Path provided for variable '{key_path}' is invalid")
|
|
617
627
|
return result
|
|
618
|
-
elif validating_type
|
|
628
|
+
elif validating_type is bool:
|
|
619
629
|
if not permissive_typing and not isinstance(value, bool):
|
|
620
630
|
raise ValueError(
|
|
621
631
|
f"Refusing to automatically convert '{value}' at '{key_path}' to a Boolean"
|
|
@@ -629,7 +639,7 @@ class Variable:
|
|
|
629
639
|
f"Value provided for variable '{key_path}' of type {validating_type.__name__} is invalid: '{value}'"
|
|
630
640
|
)
|
|
631
641
|
elif issubclass(validating_type, Enum):
|
|
632
|
-
if type(value)
|
|
642
|
+
if type(value) is validating_type:
|
|
633
643
|
return value
|
|
634
644
|
try:
|
|
635
645
|
return validating_type[value]
|
|
@@ -23,7 +23,7 @@ librelane/config/flow.py,sha256=Dr2i9MlCcGFg_ilCpeys3vPo_DLDb1yF6yGrMCZZabE,1700
|
|
|
23
23
|
librelane/config/pdk_compat.py,sha256=ofqYuD-MgTcfvPVXpGJo8H1GKzCvN6sxHsK_OqCVXa8,12870
|
|
24
24
|
librelane/config/preprocessor.py,sha256=ATi29SHz0_OBq1IqUkGxvhHUDKB5z5jO0KqvoQXg8R8,14913
|
|
25
25
|
librelane/config/removals.py,sha256=vxqTuRTJ0jt2TX4KmFZCZPTwghDFkCVjIhF2iReHwJA,2958
|
|
26
|
-
librelane/config/variable.py,sha256=
|
|
26
|
+
librelane/config/variable.py,sha256=SKhMJT3jnJt7w3vZacD8_4n5YUH3hecG0iAnHjZrkPk,27162
|
|
27
27
|
librelane/container.py,sha256=7w_V2Fpb3dbnZ8FqBce1vK31jH30UrxByppfEJRyG9M,8672
|
|
28
28
|
librelane/env_info.py,sha256=xF9iqwwJv5yZz7n7BTrrT_yP3Dp1HjAOUObNE9k_1g4,11074
|
|
29
29
|
librelane/examples/spm/config.yaml,sha256=H2ERY4xoIeXN7kM3N9yGWiFBbtByyaN2Ni1kFqYPtO4,612
|
|
@@ -167,7 +167,7 @@ librelane/steps/step.py,sha256=tYTN5QzX0huhFMLegpir4mPi3q9QAVSFZ7kchW6OECk,55849
|
|
|
167
167
|
librelane/steps/tclstep.py,sha256=68AjCmbLhBscbzQDxRcPQVU-6UvZQNOalO7qNwUXCa4,10138
|
|
168
168
|
librelane/steps/verilator.py,sha256=m3vcsBStF4i1eutzHdWHPGGoSEBwQrCKMY2k-1qJbMI,8964
|
|
169
169
|
librelane/steps/yosys.py,sha256=lYdZPFvjcmdu_NE6rtB94_dysIK2qwGdGb480W6pg2w,12711
|
|
170
|
-
librelane-3.0.0.
|
|
171
|
-
librelane-3.0.0.
|
|
172
|
-
librelane-3.0.0.
|
|
173
|
-
librelane-3.0.0.
|
|
170
|
+
librelane-3.0.0.dev41.dist-info/METADATA,sha256=IWt1bBVIxOSC6exjyQarc_1wI8h6uZL7enhkjvTbS7U,6572
|
|
171
|
+
librelane-3.0.0.dev41.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
172
|
+
librelane-3.0.0.dev41.dist-info/entry_points.txt,sha256=Ub2wE2U4uZPjJgBVTPYFeXtwhNyqAqaKT8q4jGoKIUk,274
|
|
173
|
+
librelane-3.0.0.dev41.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|