hydra-python 0.17.4__tar.gz → 0.17.6__tar.gz
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.
- {hydra_python-0.17.4 → hydra_python-0.17.6}/PKG-INFO +4 -4
- {hydra_python-0.17.4 → hydra_python-0.17.6}/README.md +1 -1
- {hydra_python-0.17.4 → hydra_python-0.17.6}/build/main/digest.json +26 -26
- {hydra_python-0.17.4 → hydra_python-0.17.6}/pyproject.toml +2 -2
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/python/coder.py +73 -71
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/python/names.py +6 -6
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/python/serde.py +10 -9
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/python/testing.py +1 -1
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/python/utils.py +10 -10
- {hydra_python-0.17.4 → hydra_python-0.17.6}/.gitignore +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.6}/LICENSE +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.6}/NOTICE +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/dsl/python/environment.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/dsl/python/names.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/dsl/python/syntax.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/dsl/python/utils.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/python/environment.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/python/language.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/python/pyproject.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.6}/src/main/python/hydra/python/syntax.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: hydra-python
|
|
3
|
-
Version: 0.17.
|
|
3
|
+
Version: 0.17.6
|
|
4
4
|
Summary: Python support for Hydra
|
|
5
5
|
Project-URL: Homepage, https://github.com/CategoricalData/hydra
|
|
6
6
|
Project-URL: Repository, https://github.com/CategoricalData/hydra
|
|
@@ -9,7 +9,7 @@ License: Apache-2.0
|
|
|
9
9
|
License-File: LICENSE
|
|
10
10
|
License-File: NOTICE
|
|
11
11
|
Requires-Python: >=3.12
|
|
12
|
-
Requires-Dist: hydra-kernel==0.17.
|
|
12
|
+
Requires-Dist: hydra-kernel==0.17.6
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
|
|
15
15
|
# Hydra-Python
|
|
@@ -398,7 +398,7 @@ of kwargs + explicit `field()`.
|
|
|
398
398
|
```python
|
|
399
399
|
@hydra_element(my_module, type_=T.function(T.int32(), T.string()))
|
|
400
400
|
def show_number(x):
|
|
401
|
-
return Strings.
|
|
401
|
+
return Strings.print_int32(x)
|
|
402
402
|
```
|
|
403
403
|
|
|
404
404
|
Idiomatic Python metadata mechanism. Risk: users may expect the
|
|
@@ -384,7 +384,7 @@ of kwargs + explicit `field()`.
|
|
|
384
384
|
```python
|
|
385
385
|
@hydra_element(my_module, type_=T.function(T.int32(), T.string()))
|
|
386
386
|
def show_number(x):
|
|
387
|
-
return Strings.
|
|
387
|
+
return Strings.print_int32(x)
|
|
388
388
|
```
|
|
389
389
|
|
|
390
390
|
Idiomatic Python metadata mechanism. Risk: users may expect the
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"digestFormatVersion": 2,
|
|
3
3
|
"moduleFormatVersion": 1,
|
|
4
|
-
"generator": "
|
|
4
|
+
"generator": "3fcbb2c3eed9a625",
|
|
5
5
|
"generation": {
|
|
6
|
-
"generatorId": "
|
|
6
|
+
"generatorId": "3fcbb2c3eed9a625",
|
|
7
7
|
"mode": "published",
|
|
8
8
|
"host": "python",
|
|
9
|
-
"hydraVersion": "0.17.
|
|
10
|
-
"revision": "
|
|
11
|
-
"timestamp": "2026-08-
|
|
12
|
-
"selfHash": "
|
|
13
|
-
"dependencyHashes": [{"key": "hydra-kernel", "value": "
|
|
9
|
+
"hydraVersion": "0.17.5",
|
|
10
|
+
"revision": "b0b667ab7e",
|
|
11
|
+
"timestamp": "2026-08-30T21:12:52Z"},
|
|
12
|
+
"selfHash": "9d63be6fefd1f95d501eb1ca75f52604f6b5ef6a37d02fe79ac24ae4608433e9",
|
|
13
|
+
"dependencyHashes": [{"key": "hydra-kernel", "value": "21db6cd59e90695a747e6be08ce6759422f84c88efd511d09ecd00fae34e4c7a"}],
|
|
14
14
|
"inputs": [
|
|
15
15
|
{
|
|
16
16
|
"key": "hydra.python.coder",
|
|
17
|
-
"value": {"kind": "other", "hash": "
|
|
17
|
+
"value": {"kind": "other", "hash": "0f6f038ef11ca726af501d1483716d1d5adff54e3c03e9a1f2cb61875260f4f7"}},
|
|
18
18
|
{
|
|
19
19
|
"key": "hydra.python.environment",
|
|
20
20
|
"value": {"kind": "other", "hash": "663b02271ddd4a6ad9ab8a2bdc152a64802a675a59280909f605d6dedcc4017e"}},
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
"value": {"kind": "other", "hash": "78fb867a1d0fa6654f46f5d9fd72c2c5607d2934b7c7fbd5f5d830786b4ad91e"}},
|
|
24
24
|
{
|
|
25
25
|
"key": "hydra.python.names",
|
|
26
|
-
"value": {"kind": "other", "hash": "
|
|
26
|
+
"value": {"kind": "other", "hash": "5bc2e53c63d41de79877fbe331aada2c7f43175b09d4245b7ac61cf8261b0ca3"}},
|
|
27
27
|
{
|
|
28
28
|
"key": "hydra.python.pyproject",
|
|
29
29
|
"value": {"kind": "other", "hash": "249512648b2b008db234ee348a72056d4d625cfeb0a80d8caacbda95002569a2"}},
|
|
30
30
|
{
|
|
31
31
|
"key": "hydra.python.serde",
|
|
32
|
-
"value": {"kind": "other", "hash": "
|
|
32
|
+
"value": {"kind": "other", "hash": "8d35f12f8ef3aa33db2064a266d6c97a31e2c8675a6f77005cdb011b01597b8a"}},
|
|
33
33
|
{
|
|
34
34
|
"key": "hydra.python.syntax",
|
|
35
35
|
"value": {"kind": "other", "hash": "88a9154b48fd429f06efa0ba8981bdf12af3fed4de5a057b3304fadc623dbc19"}},
|
|
36
36
|
{
|
|
37
37
|
"key": "hydra.python.testing",
|
|
38
|
-
"value": {"kind": "other", "hash": "
|
|
38
|
+
"value": {"kind": "other", "hash": "52629d9f9aba82fbae03c9250b42d962eea9b2cdfde77c02466282ab95c51b5b"}},
|
|
39
39
|
{
|
|
40
40
|
"key": "hydra.python.utils",
|
|
41
|
-
"value": {"kind": "other", "hash": "
|
|
41
|
+
"value": {"kind": "other", "hash": "dee99428120e9ed4b418ca438480434cc967a13ac1d918385d9fb2b1d76afeb7"}},
|
|
42
42
|
{
|
|
43
43
|
"key": "jsonContent:hydra/dsl/python/environment.json",
|
|
44
44
|
"value": {"kind": "other", "hash": "684965cea67ad57d492b50f408c6575f679b073c5de5e76826fb0941da86ec21"}},
|
|
@@ -53,31 +53,31 @@
|
|
|
53
53
|
"value": {"kind": "other", "hash": "7a3b84d522c420db0db03a77f9e54635b33544f73eb49ed67cdc3a4d5dac04ae"}},
|
|
54
54
|
{
|
|
55
55
|
"key": "jsonContent:hydra/python/coder.json",
|
|
56
|
-
"value": {"kind": "other", "hash": "
|
|
56
|
+
"value": {"kind": "other", "hash": "ebc4bdd1c21d9af2f90f408414d22313b1d1c2750f6c792c2ebed8ea9793336e"}},
|
|
57
57
|
{
|
|
58
58
|
"key": "jsonContent:hydra/python/environment.json",
|
|
59
|
-
"value": {"kind": "other", "hash": "
|
|
59
|
+
"value": {"kind": "other", "hash": "27b358d874d0de0b7cd8b2ded9194c6ae0ac30069f26eb6d658e768ff9414825"}},
|
|
60
60
|
{
|
|
61
61
|
"key": "jsonContent:hydra/python/language.json",
|
|
62
|
-
"value": {"kind": "other", "hash": "
|
|
62
|
+
"value": {"kind": "other", "hash": "f5f154079126771b9af2a4df8e53a4e9c75bb44ee3f154f4f0ce762744785b88"}},
|
|
63
63
|
{
|
|
64
64
|
"key": "jsonContent:hydra/python/names.json",
|
|
65
|
-
"value": {"kind": "other", "hash": "
|
|
65
|
+
"value": {"kind": "other", "hash": "6997d344c45c2a774b8e5d354f67c06358a7f06c91317d6100b25573cb11b7ab"}},
|
|
66
66
|
{
|
|
67
67
|
"key": "jsonContent:hydra/python/pyproject.json",
|
|
68
|
-
"value": {"kind": "other", "hash": "
|
|
68
|
+
"value": {"kind": "other", "hash": "eacea3b3d38c4890c693a012d3cd71f02e96c25c131cef8a0aa90a30442f8a7f"}},
|
|
69
69
|
{
|
|
70
70
|
"key": "jsonContent:hydra/python/serde.json",
|
|
71
|
-
"value": {"kind": "other", "hash": "
|
|
71
|
+
"value": {"kind": "other", "hash": "1428720f350e9f76ab293116b4ebf7d384d8e78dc6b62f5220d3ef30c26f9585"}},
|
|
72
72
|
{
|
|
73
73
|
"key": "jsonContent:hydra/python/syntax.json",
|
|
74
|
-
"value": {"kind": "other", "hash": "
|
|
74
|
+
"value": {"kind": "other", "hash": "a6ddfec03413c23fd3830501c58eb4350b046b6b654faa51f49ffe9aab5b995c"}},
|
|
75
75
|
{
|
|
76
76
|
"key": "jsonContent:hydra/python/testing.json",
|
|
77
|
-
"value": {"kind": "other", "hash": "
|
|
77
|
+
"value": {"kind": "other", "hash": "eb35348cdf17021c1480d2b3ec001d4e5326f7d5b934325cb7294553d2ff64d2"}},
|
|
78
78
|
{
|
|
79
79
|
"key": "jsonContent:hydra/python/utils.json",
|
|
80
|
-
"value": {"kind": "other", "hash": "
|
|
80
|
+
"value": {"kind": "other", "hash": "cae0b4fac77fdae05b5592f671b9c58f84d3374f94acbe3d49f27962096d1a5e"}},
|
|
81
81
|
{
|
|
82
82
|
"key": "jsonContent:manifest.json",
|
|
83
83
|
"value": {"kind": "other", "hash": "3f94b521766d042381d7bee84596308ea4e35c7e8fb45f8fd8338a8dbe27a0ac"}}],
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"value": {"kind": "targetFile", "hash": "3fed9996a3f875a53675b6c8620884949adf7d155b0e68cacfba9007d5d07b29"}},
|
|
97
97
|
{
|
|
98
98
|
"key": "hydra/python/coder.py",
|
|
99
|
-
"value": {"kind": "targetFile", "hash": "
|
|
99
|
+
"value": {"kind": "targetFile", "hash": "d7e39526e1f7802a5af9d6ea57596766be03b9e16505095c57597f8903683461"}},
|
|
100
100
|
{
|
|
101
101
|
"key": "hydra/python/environment.py",
|
|
102
102
|
"value": {"kind": "targetFile", "hash": "1036eb9d285ba3e98c85095820f2e77900334340c9f0223fd4dfd6b3e847f4df"}},
|
|
@@ -105,19 +105,19 @@
|
|
|
105
105
|
"value": {"kind": "targetFile", "hash": "7ea0c3a6015ec1de92aebeed0963c1af9f3b70c8d57815e477c528c795383604"}},
|
|
106
106
|
{
|
|
107
107
|
"key": "hydra/python/names.py",
|
|
108
|
-
"value": {"kind": "targetFile", "hash": "
|
|
108
|
+
"value": {"kind": "targetFile", "hash": "3e8498f205a99ebfaa570a44ccac515b69ced9d7f3669a32f74d4d05d48204b6"}},
|
|
109
109
|
{
|
|
110
110
|
"key": "hydra/python/pyproject.py",
|
|
111
111
|
"value": {"kind": "targetFile", "hash": "1f9001d8d2273d4783105e099b874c273ce520b58456f9b447cb8d5e9a6a37d7"}},
|
|
112
112
|
{
|
|
113
113
|
"key": "hydra/python/serde.py",
|
|
114
|
-
"value": {"kind": "targetFile", "hash": "
|
|
114
|
+
"value": {"kind": "targetFile", "hash": "1f36ea2dc8c50df72abe464cd395689c71f0af70a9f78e68d26013f9b436c383"}},
|
|
115
115
|
{
|
|
116
116
|
"key": "hydra/python/syntax.py",
|
|
117
117
|
"value": {"kind": "targetFile", "hash": "24a72af882b47d80cc930f16f51a3e9c1a71c9d8da47a921829f40e847459fca"}},
|
|
118
118
|
{
|
|
119
119
|
"key": "hydra/python/testing.py",
|
|
120
|
-
"value": {"kind": "targetFile", "hash": "
|
|
120
|
+
"value": {"kind": "targetFile", "hash": "5c8f352d976eeeebf14974e9df208b53c8db59810fdbd76e6454868627122635"}},
|
|
121
121
|
{
|
|
122
122
|
"key": "hydra/python/utils.py",
|
|
123
|
-
"value": {"kind": "targetFile", "hash": "
|
|
123
|
+
"value": {"kind": "targetFile", "hash": "2cfa00436ebc27925f9b45380792aa817921bb7dbaf88e0c17cfb51bbe3c82fc"}}]}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
[project]
|
|
15
15
|
name = "hydra-python"
|
|
16
|
-
version = "0.17.
|
|
16
|
+
version = "0.17.6"
|
|
17
17
|
description = "Python support for Hydra"
|
|
18
18
|
readme = "README.md"
|
|
19
19
|
requires-python = ">=3.12"
|
|
@@ -22,7 +22,7 @@ authors = [
|
|
|
22
22
|
{ name = "Joshua Shinavier", email = "josh@fortytwo.net" },
|
|
23
23
|
]
|
|
24
24
|
dependencies = [
|
|
25
|
-
"hydra-kernel == 0.17.
|
|
25
|
+
"hydra-kernel == 0.17.6",
|
|
26
26
|
]
|
|
27
27
|
|
|
28
28
|
[project.urls]
|
|
@@ -339,11 +339,11 @@ def deduplicate_case_variables(cases_: Sequence[hydra.core.CaseAlternative]) ->
|
|
|
339
339
|
v = lam.parameter
|
|
340
340
|
mdom = lam.domain
|
|
341
341
|
body = lam.body
|
|
342
|
-
return hydra.overlay.python.lib.optionals.
|
|
342
|
+
return hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.maps.lookup(v, count_by_name()),
|
|
343
343
|
(lambda : (hydra.overlay.python.lib.maps.insert(v, 1, count_by_name()), hydra.overlay.python.lib.lists.cons(field, done()))),
|
|
344
344
|
(lambda count: (
|
|
345
345
|
count2 := Lazy((lambda : hydra.overlay.python.lib.math.add(count, 1))),
|
|
346
|
-
v2 := Lazy((lambda : hydra.core.Name(hydra.overlay.python.lib.strings.concat2(v.value, hydra.overlay.python.lib.literals.
|
|
346
|
+
v2 := Lazy((lambda : hydra.core.Name(hydra.overlay.python.lib.strings.concat2(v.value, hydra.overlay.python.lib.literals.print_int32(count2.get()))))),
|
|
347
347
|
new_body := Lazy((lambda : hydra.reduction.alpha_convert(v, v2.get(), body))),
|
|
348
348
|
new_lam := Lazy((lambda : hydra.core.Lambda(v2.get(), mdom, new_body.get()))),
|
|
349
349
|
new_term := Lazy((lambda : cast(hydra.core.Term, hydra.core.TermLambda(new_lam.get())))),
|
|
@@ -444,7 +444,7 @@ def encode_float_value_py_special_float(value: str) -> hydra.python.syntax.Expre
|
|
|
444
444
|
ConsList.of(hydra.python.utils.single_quoted_string(value)))
|
|
445
445
|
|
|
446
446
|
def encode_float_value_encode_float32(v: float) -> Either[T0, hydra.python.syntax.Expression]:
|
|
447
|
-
s = Lazy((lambda : hydra.overlay.python.lib.literals.
|
|
447
|
+
s = Lazy((lambda : hydra.overlay.python.lib.literals.print_float32(v)))
|
|
448
448
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(s(), "NaN"),
|
|
449
449
|
(lambda : Right(encode_float_value_py_special_float("nan"))),
|
|
450
450
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(s(), "Infinity"),
|
|
@@ -455,7 +455,7 @@ def encode_float_value_encode_float32(v: float) -> Either[T0, hydra.python.synta
|
|
|
455
455
|
hydra.python.syntax.AtomNumber(cast(hydra.python.syntax.Number, hydra.python.syntax.NumberFloat(hydra.overlay.python.lib.literals.float32_to_float64(v)))))))))))))
|
|
456
456
|
|
|
457
457
|
def encode_float_value_encode_float64(v: float) -> Either[T0, hydra.python.syntax.Expression]:
|
|
458
|
-
s = Lazy((lambda : hydra.overlay.python.lib.literals.
|
|
458
|
+
s = Lazy((lambda : hydra.overlay.python.lib.literals.print_float64(v)))
|
|
459
459
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(s(), "NaN"),
|
|
460
460
|
(lambda : Right(encode_float_value_py_special_float("nan"))),
|
|
461
461
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(s(), "Infinity"),
|
|
@@ -538,7 +538,7 @@ def encode_literal(lit: hydra.core.Literal) -> Either[T0, hydra.python.syntax.Ex
|
|
|
538
538
|
|
|
539
539
|
case hydra.core.LiteralDecimal(value=d):
|
|
540
540
|
return Right(hydra.python.utils.function_call(hydra.python.utils.py_name_to_py_primary(hydra.python.syntax.Name("Decimal")),
|
|
541
|
-
ConsList.of(hydra.python.utils.single_quoted_string(hydra.overlay.python.lib.literals.
|
|
541
|
+
ConsList.of(hydra.python.utils.single_quoted_string(hydra.overlay.python.lib.literals.print_decimal(d)))))
|
|
542
542
|
|
|
543
543
|
case hydra.core.LiteralFloat(value=f):
|
|
544
544
|
return encode_float_value(f)
|
|
@@ -891,8 +891,8 @@ def lazy_dot_get(expr: hydra.python.syntax.Expression) -> hydra.python.syntax.Ex
|
|
|
891
891
|
def make_simple_lambda(arity: int, lhs: hydra.python.syntax.Expression) -> hydra.python.syntax.Expression:
|
|
892
892
|
r"""Wrap a bare reference to a polymorphic function in an uncurried lambda."""
|
|
893
893
|
|
|
894
|
-
args = Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda i: hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2("x", hydra.overlay.python.lib.literals.
|
|
895
|
-
hydra.overlay.python.lib.math.range_(1, arity))))
|
|
894
|
+
args = Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda i: hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2("x", hydra.overlay.python.lib.literals.print_int32(i)))),
|
|
895
|
+
hydra.overlay.python.lib.math.range_(1, hydra.overlay.python.lib.math.add(arity, 1)))))
|
|
896
896
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(arity, 0),
|
|
897
897
|
(lambda : lhs),
|
|
898
898
|
(lambda : cast(hydra.python.syntax.Expression,
|
|
@@ -945,10 +945,10 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
945
945
|
as_function_call = Lazy((lambda : hydra.python.utils.function_call(hydra.python.utils.py_name_to_py_primary(hydra.python.names.encode_name(True, hydra.util.CaseConvention.LOWER_SNAKE, env, name)),
|
|
946
946
|
args)))
|
|
947
947
|
as_lazy_call = Lazy((lambda : hydra.python.utils.function_call(hydra.python.utils.py_expression_to_py_primary(lazy_dot_get(as_variable())), args)))
|
|
948
|
-
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.
|
|
948
|
+
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.is_empty(args)),
|
|
949
949
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.sets.member(name, inline_vars),
|
|
950
950
|
(lambda : Right(as_lazy_call())),
|
|
951
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
951
|
+
(lambda : hydra.overlay.python.lib.optionals.match(hydra.lexical.lookup_primitive(g(), name),
|
|
952
952
|
(lambda : Right(as_function_call())),
|
|
953
953
|
(lambda prim: (
|
|
954
954
|
prim_arity := Lazy((lambda : hydra.arity.primitive_arity(prim))),
|
|
@@ -957,8 +957,8 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
957
957
|
(lambda : (
|
|
958
958
|
num_remaining := Lazy((lambda : hydra.overlay.python.lib.math.sub(prim_arity.get(), hydra.overlay.python.lib.lists.length(args)))),
|
|
959
959
|
(
|
|
960
|
-
remaining_params := Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda i: hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2("x", hydra.overlay.python.lib.literals.
|
|
961
|
-
hydra.overlay.python.lib.math.range_(1, num_remaining.get())))),
|
|
960
|
+
remaining_params := Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda i: hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2("x", hydra.overlay.python.lib.literals.print_int32(i)))),
|
|
961
|
+
hydra.overlay.python.lib.math.range_(1, hydra.overlay.python.lib.math.add(num_remaining.get(), 1))))),
|
|
962
962
|
(
|
|
963
963
|
remaining_exprs := Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda n: cast(hydra.python.syntax.Expression,
|
|
964
964
|
hydra.python.syntax.ExpressionSimple(hydra.python.syntax.Disjunction(ConsList.of(hydra.python.syntax.Conjunction(ConsList.of(cast(hydra.python.syntax.Inversion,
|
|
@@ -981,27 +981,27 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
981
981
|
full_call := Lazy((lambda : hydra.python.utils.function_call(hydra.python.utils.py_name_to_py_primary(hydra.python.names.encode_name(True, hydra.util.CaseConvention.LOWER_SNAKE, env, name)),
|
|
982
982
|
all_args.get()))),
|
|
983
983
|
Right(make_uncurried_lambda(remaining_params.get(), full_call.get())))[1])[1])[1])[1])[1])))[1]))))),
|
|
984
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
984
|
+
(lambda : hydra.overlay.python.lib.optionals.match(m_typ(),
|
|
985
985
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.sets.member(name, tc_lambda_vars),
|
|
986
986
|
(lambda : Right(as_variable())),
|
|
987
987
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.sets.member(name, inline_vars),
|
|
988
988
|
(lambda : Right(lazy_dot_get(as_variable()))),
|
|
989
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
990
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
991
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
989
|
+
(lambda : hydra.overlay.python.lib.optionals.match(hydra.lexical.lookup_primitive(g(), name),
|
|
990
|
+
(lambda : hydra.overlay.python.lib.optionals.match(hydra.lexical.lookup_binding(g(), name),
|
|
991
|
+
(lambda : hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.maps.lookup(name, tc_metadata),
|
|
992
992
|
(lambda : Left(cast(hydra.errors.Error,
|
|
993
993
|
hydra.errors.ErrorOther(hydra.errors.OtherError(hydra.overlay.python.lib.strings.concat2("Unknown variable: ", name.value)))))),
|
|
994
994
|
(lambda _: Right(as_function_call())))),
|
|
995
995
|
(lambda el: (
|
|
996
996
|
el_trivial1 := Lazy((lambda : hydra.predicates.is_trivial_term(el.term))),
|
|
997
|
-
hydra.overlay.python.lib.optionals.
|
|
997
|
+
hydra.overlay.python.lib.optionals.match(el.type_scheme,
|
|
998
998
|
(lambda : Right(as_variable())),
|
|
999
999
|
(lambda ts: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.equality.equal(hydra.arity.type_scheme_arity(ts), 0),
|
|
1000
1000
|
hydra.predicates.is_complex_binding(tc, el)),
|
|
1001
1001
|
hydra.overlay.python.lib.logic.not_(el_trivial1.get())),
|
|
1002
1002
|
(lambda : Right(as_function_call())),
|
|
1003
1003
|
(lambda : (
|
|
1004
|
-
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.
|
|
1004
|
+
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.is_empty(ts.variables)),
|
|
1005
1005
|
(lambda : make_simple_lambda(hydra.arity.type_arity(ts.body), as_variable())),
|
|
1006
1006
|
(lambda : as_variable())))),
|
|
1007
1007
|
Right(as_function_ref.get()))[1])))))[1]))),
|
|
@@ -1012,7 +1012,7 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
1012
1012
|
(lambda : (
|
|
1013
1013
|
ts := Lazy((lambda : hydra.scoping.term_signature_to_type_scheme(prim.definition.signature))),
|
|
1014
1014
|
(
|
|
1015
|
-
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.
|
|
1015
|
+
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.is_empty(ts.get().variables)),
|
|
1016
1016
|
(lambda : make_simple_lambda(hydra.arity.type_arity(ts.get().body), as_variable())),
|
|
1017
1017
|
(lambda : as_variable())))),
|
|
1018
1018
|
Right(as_function_ref.get()))[1])[1])))[1]))))))),
|
|
@@ -1022,25 +1022,25 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
1022
1022
|
(lambda : (
|
|
1023
1023
|
unwrapped := Lazy((lambda : lazy_dot_get(as_variable()))),
|
|
1024
1024
|
(
|
|
1025
|
-
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.
|
|
1025
|
+
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.is_empty(hydra.variables.free_variables_in_type(typ))),
|
|
1026
1026
|
(lambda : make_simple_lambda(hydra.arity.type_arity(typ), unwrapped.get())),
|
|
1027
1027
|
(lambda : unwrapped.get())))),
|
|
1028
1028
|
Right(as_function_ref.get()))[1])[1]),
|
|
1029
1029
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.maps.member(name, tc_metadata)),
|
|
1030
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
1030
|
+
(lambda : hydra.overlay.python.lib.optionals.match(hydra.lexical.lookup_binding(g(), name),
|
|
1031
1031
|
(lambda : (
|
|
1032
|
-
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.
|
|
1032
|
+
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.is_empty(hydra.variables.free_variables_in_type(typ))),
|
|
1033
1033
|
(lambda : make_simple_lambda(hydra.arity.type_arity(typ), as_variable())),
|
|
1034
1034
|
(lambda : as_variable())))),
|
|
1035
1035
|
Right(as_function_ref.get()))[1]),
|
|
1036
1036
|
(lambda el: (
|
|
1037
1037
|
el_trivial := Lazy((lambda : hydra.predicates.is_trivial_term(el.term))),
|
|
1038
|
-
hydra.overlay.python.lib.optionals.
|
|
1038
|
+
hydra.overlay.python.lib.optionals.match(el.type_scheme,
|
|
1039
1039
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.equality.equal(hydra.arity.type_arity(typ), 0),
|
|
1040
1040
|
hydra.overlay.python.lib.logic.not_(el_trivial.get())),
|
|
1041
1041
|
(lambda : Right(as_function_call())),
|
|
1042
1042
|
(lambda : (
|
|
1043
|
-
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.
|
|
1043
|
+
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.is_empty(hydra.variables.free_variables_in_type(typ))),
|
|
1044
1044
|
(lambda : make_simple_lambda(hydra.arity.type_arity(typ), as_variable())),
|
|
1045
1045
|
(lambda : as_variable())))),
|
|
1046
1046
|
Right(as_function_ref.get()))[1]))),
|
|
@@ -1048,14 +1048,14 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
1048
1048
|
hydra.overlay.python.lib.logic.not_(el_trivial.get())),
|
|
1049
1049
|
(lambda : Right(as_function_call())),
|
|
1050
1050
|
(lambda : (
|
|
1051
|
-
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.
|
|
1051
|
+
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.is_empty(hydra.variables.free_variables_in_type(typ))),
|
|
1052
1052
|
(lambda : make_simple_lambda(hydra.arity.type_arity(typ), as_variable())),
|
|
1053
1053
|
(lambda : as_variable())))),
|
|
1054
1054
|
Right(as_function_ref.get()))[1])))))[1]))),
|
|
1055
1055
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.equality.equal(hydra.arity.type_arity(typ), 0), hydra.predicates.is_complex_variable(tc, name)),
|
|
1056
1056
|
(lambda : Right(as_function_call())),
|
|
1057
1057
|
(lambda : (
|
|
1058
|
-
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.
|
|
1058
|
+
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.is_empty(hydra.variables.free_variables_in_type(typ))),
|
|
1059
1059
|
(lambda : make_simple_lambda(hydra.arity.type_arity(typ), as_variable())),
|
|
1060
1060
|
(lambda : as_variable())))),
|
|
1061
1061
|
Right(as_function_ref.get()))[1]))))))))))))
|
|
@@ -1128,7 +1128,7 @@ v3: Callable[[hydra.python.environment.PythonEnvironment], T0]) -> T0:
|
|
|
1128
1128
|
def lazy_flags_for_primitive(g: hydra.graph.Graph, name: hydra.core.Name) -> Sequence[bool]:
|
|
1129
1129
|
r"""Per-parameter isLazy flags of a primitive (by name), or empty if not a primitive. Single source of truth for which arguments coders thunk; replaces hard-coded name tables (issue #391)."""
|
|
1130
1130
|
|
|
1131
|
-
return hydra.overlay.python.lib.optionals.
|
|
1131
|
+
return hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.maps.lookup(name, g.primitives),
|
|
1132
1132
|
(lambda : ConsList.of()),
|
|
1133
1133
|
(lambda prim: (
|
|
1134
1134
|
def0 := Lazy((lambda : prim.definition)),
|
|
@@ -1164,9 +1164,9 @@ def term_arity_with_primitives(graph: hydra.graph.Graph, term: hydra.core.Term)
|
|
|
1164
1164
|
return 1
|
|
1165
1165
|
|
|
1166
1166
|
case hydra.core.TermVariable(value=name):
|
|
1167
|
-
return hydra.overlay.python.lib.optionals.
|
|
1167
|
+
return hydra.overlay.python.lib.optionals.match(hydra.lexical.lookup_binding(graph, name),
|
|
1168
1168
|
(lambda : 0),
|
|
1169
|
-
(lambda el: hydra.overlay.python.lib.optionals.
|
|
1169
|
+
(lambda el: hydra.overlay.python.lib.optionals.match(el.type_scheme, (lambda : hydra.arity.term_arity(el.term)), (lambda ts: hydra.arity.type_scheme_arity(ts)))))
|
|
1170
1170
|
|
|
1171
1171
|
case _:
|
|
1172
1172
|
return 0
|
|
@@ -1205,7 +1205,7 @@ rargs: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, t
|
|
|
1205
1205
|
hydra.overlay.python.lib.lists.head(hargs))))
|
|
1206
1206
|
rest_args = Lazy((lambda : hydra.overlay.python.lib.lists.drop(1, hargs)))
|
|
1207
1207
|
def with_rest(e: hydra.python.syntax.Expression) -> hydra.python.syntax.Expression:
|
|
1208
|
-
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
1208
|
+
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(rest_args()),
|
|
1209
1209
|
(lambda : e),
|
|
1210
1210
|
(lambda : hydra.python.utils.function_call(hydra.python.utils.py_expression_to_py_primary(e), rest_args())))
|
|
1211
1211
|
default_case = Lazy((lambda : hydra.overlay.python.lib.eithers.bind(encode_term_inline(cx, env, False, fun),
|
|
@@ -1222,7 +1222,7 @@ rargs: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, t
|
|
|
1222
1222
|
case hydra.core.TermUnwrap():
|
|
1223
1223
|
value_expr = Lazy((lambda : hydra.python.utils.project_from_expression(first_arg(), hydra.python.syntax.Name("value"))))
|
|
1224
1224
|
all_args = Lazy((lambda : hydra.overlay.python.lib.lists.concat2(rest_args(), rargs)))
|
|
1225
|
-
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
1225
|
+
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(all_args()),
|
|
1226
1226
|
(lambda : Right((value_expr(), ConsList.of()))),
|
|
1227
1227
|
(lambda : Right((
|
|
1228
1228
|
hydra.python.utils.function_call(hydra.python.utils.py_expression_to_py_primary(value_expr()), all_args()),
|
|
@@ -1236,17 +1236,17 @@ rargs: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, t
|
|
|
1236
1236
|
g = Lazy((lambda : python_environment_get_graph(env)))
|
|
1237
1237
|
all_args = Lazy((lambda : hydra.overlay.python.lib.lists.concat2(hargs, rargs)))
|
|
1238
1238
|
inline_vars = env.inline_variables
|
|
1239
|
-
return hydra.overlay.python.lib.optionals.
|
|
1240
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
1239
|
+
return hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.maps.lookup(name, g().primitives),
|
|
1240
|
+
(lambda : hydra.overlay.python.lib.optionals.match(hydra.lexical.lookup_binding(g(), name),
|
|
1241
1241
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_variable(cx, env, name, hargs), (lambda expr: Right((expr, rargs))))),
|
|
1242
|
-
(lambda el: hydra.overlay.python.lib.optionals.
|
|
1242
|
+
(lambda el: hydra.overlay.python.lib.optionals.match(el.type_scheme,
|
|
1243
1243
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_variable(cx, env, name, hargs), (lambda expr: Right((expr, rargs))))),
|
|
1244
1244
|
(lambda ts: (
|
|
1245
1245
|
el_arity := Lazy((lambda : hydra.arity.type_scheme_arity(ts))),
|
|
1246
1246
|
consume_count := Lazy((lambda : hydra.overlay.python.lib.ordering.min(el_arity.get(), hydra.overlay.python.lib.lists.length(all_args())))),
|
|
1247
1247
|
consumed_args := Lazy((lambda : hydra.overlay.python.lib.lists.take(consume_count.get(), all_args()))),
|
|
1248
1248
|
remaining_args := Lazy((lambda : hydra.overlay.python.lib.lists.drop(consume_count.get(), all_args()))),
|
|
1249
|
-
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
1249
|
+
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(consumed_args.get()),
|
|
1250
1250
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_variable(cx, env, name, ConsList.of()), (lambda expr: Right((expr, rargs))))),
|
|
1251
1251
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.sets.member(name, inline_vars),
|
|
1252
1252
|
(lambda : Right((
|
|
@@ -1282,7 +1282,7 @@ binding: hydra.core.Binding) -> Either[hydra.errors.Error, hydra.python.syntax.N
|
|
|
1282
1282
|
is_trivial := Lazy((lambda : hydra.predicates.is_trivial_term(term))),
|
|
1283
1283
|
needs_thunk := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(is_trivial.get(),
|
|
1284
1284
|
(lambda : False),
|
|
1285
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
1285
|
+
(lambda : hydra.overlay.python.lib.optionals.match(mts,
|
|
1286
1286
|
(lambda : hydra.overlay.python.lib.logic.and_(allow_thunking, hydra.overlay.python.lib.logic.or_(is_complex_var.get(), term_is_complex.get()))),
|
|
1287
1287
|
(lambda ts: hydra.overlay.python.lib.logic.and_(allow_thunking,
|
|
1288
1288
|
hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.equality.equal(hydra.arity.type_scheme_arity(ts), 0),
|
|
@@ -1350,7 +1350,7 @@ def encode_term_inline(cx: hydra.typing.InferenceContext, env: hydra.python.envi
|
|
|
1350
1350
|
(lambda pbody: (
|
|
1351
1351
|
pparams := Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda v1: hydra.python.names.encode_name(False, hydra.util.CaseConvention.LOWER_SNAKE, inner_env.get(), v1)),
|
|
1352
1352
|
params.get()))),
|
|
1353
|
-
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
1353
|
+
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(bindings.get()),
|
|
1354
1354
|
(lambda : Right(make_uncurried_lambda(pparams.get(), pbody))),
|
|
1355
1355
|
(lambda : hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.eithers.map_list((lambda v1: encode_binding_as_assignment(cx, False, inner_env.get(), v1)), bindings.get()),
|
|
1356
1356
|
(lambda pbinding_exprs: (
|
|
@@ -1408,7 +1408,7 @@ def encode_term_inline(cx: hydra.typing.InferenceContext, env: hydra.python.envi
|
|
|
1408
1408
|
case hydra.core.TermLet(value=lt):
|
|
1409
1409
|
bindings = lt.bindings
|
|
1410
1410
|
body = lt.body
|
|
1411
|
-
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
1411
|
+
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(bindings),
|
|
1412
1412
|
(lambda : encode_term_inline(cx, env, False, body)),
|
|
1413
1413
|
(lambda : with_let_inline(env,
|
|
1414
1414
|
lt,
|
|
@@ -1451,7 +1451,7 @@ def encode_term_inline(cx: hydra.typing.InferenceContext, env: hydra.python.envi
|
|
|
1451
1451
|
Right(hydra.python.utils.function_call(hydra.python.utils.py_expression_to_py_primary(pmap_of_entries.get()), tuple_pairs)))[1]))
|
|
1452
1452
|
|
|
1453
1453
|
case hydra.core.TermOptional(value=mt):
|
|
1454
|
-
return hydra.overlay.python.lib.optionals.
|
|
1454
|
+
return hydra.overlay.python.lib.optionals.match(mt,
|
|
1455
1455
|
(lambda : Right(hydra.python.utils.function_call(hydra.python.utils.py_name_to_py_primary(hydra.python.syntax.Name("None_")), ConsList.of()))),
|
|
1456
1456
|
(lambda t1: hydra.overlay.python.lib.eithers.bind(encode(t1),
|
|
1457
1457
|
(lambda pyexp: with_cast(hydra.python.utils.function_call(hydra.python.utils.py_name_to_py_primary(hydra.python.syntax.Name("Given")), ConsList.of(pyexp)))))))
|
|
@@ -1495,7 +1495,7 @@ def encode_term_inline(cx: hydra.typing.InferenceContext, env: hydra.python.envi
|
|
|
1495
1495
|
(lambda : (
|
|
1496
1496
|
fname := Lazy((lambda : field.name)),
|
|
1497
1497
|
(
|
|
1498
|
-
is_unit_variant := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
1498
|
+
is_unit_variant := Lazy((lambda : hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.lists.find((lambda ft: hydra.overlay.python.lib.equality.equal(ft.name.value, fname.get().value)), rt),
|
|
1499
1499
|
(lambda : False),
|
|
1500
1500
|
(lambda ft: hydra.predicates.is_unit_type(hydra.strip.deannotate_type(ft.type)))))),
|
|
1501
1501
|
hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.or_(hydra.predicates.is_unit_term(field.term), is_unit_variant.get()),
|
|
@@ -1535,7 +1535,7 @@ py_arg: hydra.python.syntax.Expression) -> Either[hydra.errors.Error, hydra.pyth
|
|
|
1535
1535
|
is_enum := Lazy((lambda : hydra.predicates.is_enum_row_type(rt))),
|
|
1536
1536
|
value_expr := Lazy((lambda : hydra.python.utils.project_from_expression(py_arg, hydra.python.syntax.Name("value")))),
|
|
1537
1537
|
isinstance_primary := Lazy((lambda : hydra.python.utils.py_name_to_py_primary(hydra.python.syntax.Name("isinstance")))),
|
|
1538
|
-
hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.optionals.
|
|
1538
|
+
hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.optionals.match(mdefault,
|
|
1539
1539
|
(lambda : Right(unsupported_expression("no matching case in inline union elimination"))),
|
|
1540
1540
|
(lambda dflt: encode_term_inline(cx, env, False, dflt))),
|
|
1541
1541
|
(lambda py_default: (
|
|
@@ -1580,7 +1580,7 @@ mdflt: Optional[T0],
|
|
|
1580
1580
|
tname: hydra.core.Name) -> Either[T1, Sequence[hydra.python.syntax.CaseBlock]]:
|
|
1581
1581
|
r"""Encode the default (wildcard) case block for a match statement."""
|
|
1582
1582
|
|
|
1583
|
-
return hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.optionals.
|
|
1583
|
+
return hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.optionals.match(mdflt,
|
|
1584
1584
|
(lambda : Right(hydra.overlay.python.lib.logic.if_else(is_full,
|
|
1585
1585
|
(lambda : hydra.python.utils.raise_assertion_error("Unreachable: all variants handled")),
|
|
1586
1586
|
(lambda : hydra.python.utils.raise_type_error(hydra.overlay.python.lib.strings.concat2("Unsupported ", hydra.names.local_name_of(tname))))))),
|
|
@@ -1754,7 +1754,7 @@ def encode_binding_as(cx: hydra.typing.InferenceContext, env: hydra.python.envir
|
|
|
1754
1754
|
term1 = binding.term
|
|
1755
1755
|
mts = binding.type_scheme
|
|
1756
1756
|
fname = Lazy((lambda : hydra.python.names.encode_name(True, hydra.util.CaseConvention.LOWER_SNAKE, env, name1)))
|
|
1757
|
-
return hydra.overlay.python.lib.optionals.
|
|
1757
|
+
return hydra.overlay.python.lib.optionals.match(mts,
|
|
1758
1758
|
(lambda : (
|
|
1759
1759
|
gathered := Lazy((lambda : gather_lambdas(term1))),
|
|
1760
1760
|
(
|
|
@@ -1763,12 +1763,12 @@ def encode_binding_as(cx: hydra.typing.InferenceContext, env: hydra.python.envir
|
|
|
1763
1763
|
inner_body := Lazy((lambda : hydra.overlay.python.lib.pairs.second(gathered.get()))),
|
|
1764
1764
|
(
|
|
1765
1765
|
mcsa := Lazy((lambda : is_case_statement_application(inner_body.get()))),
|
|
1766
|
-
hydra.overlay.python.lib.optionals.
|
|
1766
|
+
hydra.overlay.python.lib.optionals.match(mcsa.get(),
|
|
1767
1767
|
(lambda : (
|
|
1768
1768
|
mcs := Lazy((lambda : extract_case_elimination(term1))),
|
|
1769
|
-
hydra.overlay.python.lib.optionals.
|
|
1769
|
+
hydra.overlay.python.lib.optionals.match(mcs.get(),
|
|
1770
1770
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_term_multiline(cx, env, term1),
|
|
1771
|
-
(lambda stmts: hydra.overlay.python.lib.optionals.
|
|
1771
|
+
(lambda stmts: hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.lists.head(stmts),
|
|
1772
1772
|
(lambda : Left(cast(hydra.errors.Error, hydra.errors.ErrorOther(hydra.errors.OtherError("encodeTermMultiline returned no statements"))))),
|
|
1773
1773
|
(lambda x: Right(x)))))),
|
|
1774
1774
|
(lambda cs: (
|
|
@@ -1799,12 +1799,12 @@ def encode_binding_as(cx: hydra.typing.InferenceContext, env: hydra.python.envir
|
|
|
1799
1799
|
Right(cast(hydra.python.syntax.Statement,
|
|
1800
1800
|
hydra.python.syntax.StatementCompound(cast(hydra.python.syntax.CompoundStatement,
|
|
1801
1801
|
hydra.python.syntax.CompoundStatementFunction(hydra.python.syntax.FunctionDefinition(None_(), func_def_raw.get())))))))[5])))))[5])))[3])))[1]),
|
|
1802
|
-
(lambda csa: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
1802
|
+
(lambda csa: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(lambda_params.get()),
|
|
1803
1803
|
(lambda : (
|
|
1804
1804
|
mcs := Lazy((lambda : extract_case_elimination(term1))),
|
|
1805
|
-
hydra.overlay.python.lib.optionals.
|
|
1805
|
+
hydra.overlay.python.lib.optionals.match(mcs.get(),
|
|
1806
1806
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_term_multiline(cx, env, term1),
|
|
1807
|
-
(lambda stmts: hydra.overlay.python.lib.optionals.
|
|
1807
|
+
(lambda stmts: hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.lists.head(stmts),
|
|
1808
1808
|
(lambda : Left(cast(hydra.errors.Error, hydra.errors.ErrorOther(hydra.errors.OtherError("encodeTermMultiline returned no statements"))))),
|
|
1809
1809
|
(lambda x: Right(x)))))),
|
|
1810
1810
|
(lambda cs: (
|
|
@@ -1909,7 +1909,7 @@ comment: Optional[str]) -> Either[hydra.errors.Error, hydra.python.syntax.Statem
|
|
|
1909
1909
|
is_complex := Lazy((lambda : hydra.predicates.is_complex_binding(tc.get(), binding.get()))),
|
|
1910
1910
|
is_trivial := Lazy((lambda : hydra.predicates.is_trivial_term(term))),
|
|
1911
1911
|
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.and_(is_complex.get(), hydra.overlay.python.lib.logic.not_(is_trivial.get())),
|
|
1912
|
-
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.logic.not_(top_level), hydra.overlay.python.lib.lists.
|
|
1912
|
+
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.logic.not_(top_level), hydra.overlay.python.lib.lists.is_empty(params.get())),
|
|
1913
1913
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_term_inline(cx, env2.get(), False, term),
|
|
1914
1914
|
(lambda body_expr: (
|
|
1915
1915
|
py_name := Lazy((lambda : hydra.python.names.encode_name(False, hydra.util.CaseConvention.LOWER_SNAKE, env2.get(), name))),
|
|
@@ -1931,7 +1931,7 @@ def encode_term_multiline(cx: hydra.typing.InferenceContext, env: hydra.python.e
|
|
|
1931
1931
|
bindings := Lazy((lambda : fs.bindings)),
|
|
1932
1932
|
inner_body := Lazy((lambda : fs.body)),
|
|
1933
1933
|
env2 := Lazy((lambda : fs.environment)),
|
|
1934
|
-
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
1934
|
+
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(bindings.get()),
|
|
1935
1935
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_term_inline(cx, env, False, term), (lambda expr: Right(ConsList.of(hydra.python.utils.return_single(expr)))))),
|
|
1936
1936
|
(lambda : hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.eithers.map_list((lambda v1: encode_binding_as(cx, env2.get(), v1)), bindings.get()),
|
|
1937
1937
|
(lambda binding_stmts: hydra.overlay.python.lib.eithers.bind(encode_term_multiline(cx, env2.get(), inner_body.get()),
|
|
@@ -1988,7 +1988,7 @@ prefixes: Sequence[hydra.python.syntax.Statement]) -> Either[hydra.errors.Error,
|
|
|
1988
1988
|
(lambda py_args: (
|
|
1989
1989
|
py_params := Lazy((lambda : cast(hydra.python.syntax.Parameters,
|
|
1990
1990
|
hydra.python.syntax.ParametersParamNoDefault(hydra.python.syntax.ParamNoDefaultParameters(py_args, ConsList.of(), None_()))))),
|
|
1991
|
-
is_t_c_o := Lazy((lambda : hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.
|
|
1991
|
+
is_t_c_o := Lazy((lambda : hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.is_empty(args)),
|
|
1992
1992
|
hydra.analysis.is_self_tail_recursive(name, body)))),
|
|
1993
1993
|
hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.logic.if_else(is_t_c_o.get(),
|
|
1994
1994
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_term_multiline_t_c_o(cx, env, name, args, body),
|
|
@@ -2002,14 +2002,14 @@ prefixes: Sequence[hydra.python.syntax.Statement]) -> Either[hydra.errors.Error,
|
|
|
2002
2002
|
Right(hydra.python.utils.indented_block(comment, ConsList.of(ConsList.of(while_stmt.get())))))[3]))),
|
|
2003
2003
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_term_multiline(cx, env, body),
|
|
2004
2004
|
(lambda stmts: Right(hydra.python.utils.indented_block(comment, ConsList.of(hydra.overlay.python.lib.lists.concat2(prefixes, stmts)))))))),
|
|
2005
|
-
(lambda block: hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.optionals.
|
|
2005
|
+
(lambda block: hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.optionals.match(mcod,
|
|
2006
2006
|
(lambda : Right(None_())),
|
|
2007
2007
|
(lambda cod: hydra.overlay.python.lib.eithers.bind(encode_type(env, cod), (lambda pytyp: Right(Given(pytyp)))))),
|
|
2008
2008
|
(lambda mreturn_type: (
|
|
2009
2009
|
py_tparams := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(use_inline_type_params(),
|
|
2010
2010
|
(lambda : hydra.overlay.python.lib.lists.map((lambda arg_: hydra.python.utils.py_name_to_py_type_parameter(hydra.python.names.encode_type_variable(arg_))), tparams)),
|
|
2011
2011
|
(lambda : ConsList.of())))),
|
|
2012
|
-
is_thunk := Lazy((lambda : hydra.overlay.python.lib.lists.
|
|
2012
|
+
is_thunk := Lazy((lambda : hydra.overlay.python.lib.lists.is_empty(args))),
|
|
2013
2013
|
m_decorators := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(is_thunk.get(), (lambda : Given(hydra.python.syntax.Decorators(ConsList.of(lru_cache_decorator())))), (lambda : None_())))),
|
|
2014
2014
|
py_name := Lazy((lambda : hydra.python.names.encode_name(False, hydra.util.CaseConvention.LOWER_SNAKE, env, name))),
|
|
2015
2015
|
Right(cast(hydra.python.syntax.Statement,
|
|
@@ -2050,7 +2050,7 @@ def encode_name_constants(env: hydra.python.environment.PythonEnvironment, name:
|
|
|
2050
2050
|
def generic_arg(tparam_list: Sequence[hydra.core.Name]) -> Optional[hydra.python.syntax.Expression]:
|
|
2051
2051
|
r"""Create Generic[...] argument expression for class definition."""
|
|
2052
2052
|
|
|
2053
|
-
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
2053
|
+
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(tparam_list),
|
|
2054
2054
|
(lambda : None_()),
|
|
2055
2055
|
(lambda : Given(hydra.python.utils.py_primary_to_py_expression(hydra.python.utils.primary_with_expression_slices(cast(hydra.python.syntax.Primary,
|
|
2056
2056
|
hydra.python.syntax.PrimarySimple(cast(hydra.python.syntax.Atom, hydra.python.syntax.AtomName(hydra.python.syntax.Name("Generic"))))),
|
|
@@ -2205,7 +2205,7 @@ comment: Optional[str]) -> Either[hydra.errors.Error, hydra.python.syntax.Statem
|
|
|
2205
2205
|
bound_vars := Lazy((lambda : env.bound_type_variables)),
|
|
2206
2206
|
tparam_list := Lazy((lambda : hydra.overlay.python.lib.pairs.first(bound_vars.get()))),
|
|
2207
2207
|
m_generic_arg := Lazy((lambda : generic_arg(tparam_list.get()))),
|
|
2208
|
-
args := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
2208
|
+
args := Lazy((lambda : hydra.overlay.python.lib.optionals.match(m_generic_arg.get(), (lambda : None_()), (lambda a: Given(hydra.python.utils.py_expressions_to_py_args(ConsList.of(a))))))),
|
|
2209
2209
|
decs := Lazy((lambda : Given(hydra.python.syntax.Decorators(ConsList.of(dataclass_decorator()))))),
|
|
2210
2210
|
py_name := Lazy((lambda : hydra.python.names.encode_name(False, hydra.util.CaseConvention.PASCAL, env, name))),
|
|
2211
2211
|
no_type_params := Lazy((lambda : ConsList.of())),
|
|
@@ -2253,7 +2253,7 @@ def encode_enum_value_assignment(cx: T0, env: hydra.python.environment.PythonEnv
|
|
|
2253
2253
|
py_value := Lazy((lambda : hydra.python.utils.function_call(hydra.python.utils.py_name_to_py_primary(hydra.python.names.encode_name(True, hydra.util.CaseConvention.PASCAL, env, hydra.core.Name("hydra.core.Name"))),
|
|
2254
2254
|
ConsList.of(hydra.python.utils.double_quoted_string(fname_str.get()))))),
|
|
2255
2255
|
assign_stmt := Lazy((lambda : hydra.python.utils.assignment_statement(py_name.get(), py_value.get()))),
|
|
2256
|
-
Right(hydra.overlay.python.lib.optionals.
|
|
2256
|
+
Right(hydra.overlay.python.lib.optionals.match(mcomment,
|
|
2257
2257
|
(lambda : ConsList.of(assign_stmt.get())),
|
|
2258
2258
|
(lambda c: ConsList.of(assign_stmt.get(), hydra.python.utils.py_expression_to_py_statement(hydra.python.utils.triple_quoted_string(c)))))))[4]))
|
|
2259
2259
|
|
|
@@ -2261,7 +2261,7 @@ def encode_type_quoted(env: hydra.python.environment.PythonEnvironment, typ: hyd
|
|
|
2261
2261
|
r"""Encode a type to a Python expression, quoting if the type has free variables."""
|
|
2262
2262
|
|
|
2263
2263
|
return hydra.overlay.python.lib.eithers.bind(encode_type(env, typ),
|
|
2264
|
-
(lambda pytype: Right(hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.sets.
|
|
2264
|
+
(lambda pytype: Right(hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.sets.is_empty(hydra.variables.free_variables_in_type(typ)),
|
|
2265
2265
|
(lambda : pytype),
|
|
2266
2266
|
(lambda : hydra.python.utils.double_quoted_string(hydra.serialization.print_expr(hydra.python.serde.expression_to_expr(pytype))))))))
|
|
2267
2267
|
|
|
@@ -2309,7 +2309,7 @@ def encode_union_field_alt(env: hydra.python.environment.PythonEnvironment, unio
|
|
|
2309
2309
|
tparam_names = Lazy((lambda : find_type_params(env, ftype)))
|
|
2310
2310
|
tparams = Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda x1: hydra.python.names.encode_type_variable(x1)), tparam_names())))
|
|
2311
2311
|
name_prim = Lazy((lambda : hydra.python.utils.py_name_to_py_primary(hydra.python.names.variant_name(False, env, union_name, fname))))
|
|
2312
|
-
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
2312
|
+
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(tparams()),
|
|
2313
2313
|
(lambda : name_prim()),
|
|
2314
2314
|
(lambda : (
|
|
2315
2315
|
tparam_exprs := Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda x1: hydra.python.utils.py_name_to_py_expression(x1)), tparams()))),
|
|
@@ -2447,8 +2447,10 @@ def encode_definition(cx: hydra.typing.InferenceContext, env: hydra.python.envir
|
|
|
2447
2447
|
case hydra.packaging.DefinitionTerm(value=td):
|
|
2448
2448
|
name = td.name
|
|
2449
2449
|
term = td.body
|
|
2450
|
-
typ = Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
2451
|
-
(lambda : hydra.core.TypeScheme(ConsList.of(),
|
|
2450
|
+
typ = Lazy((lambda : hydra.overlay.python.lib.optionals.match(td.signature,
|
|
2451
|
+
(lambda : hydra.core.TypeScheme(ConsList.of(),
|
|
2452
|
+
cast(hydra.core.Type, hydra.core.TypeVariable(hydra.core.Name("hydra.core.Unit"))),
|
|
2453
|
+
hydra.overlay.python.lib.maps.empty())),
|
|
2452
2454
|
(lambda sig: hydra.scoping.term_signature_to_type_scheme(sig)))))
|
|
2453
2455
|
return hydra.overlay.python.lib.eithers.bind(hydra.annotations.get_term_description(cx, python_environment_get_graph(env), term),
|
|
2454
2456
|
(lambda comment: (
|
|
@@ -2818,7 +2820,7 @@ def extend_meta_for_type(top_level: bool, is_term_annot: bool, typ: hydra.core.T
|
|
|
2818
2820
|
case hydra.core.TypeUnion(value=rt):
|
|
2819
2821
|
return hydra.overlay.python.lib.logic.if_else(hydra.predicates.is_enum_row_type(rt),
|
|
2820
2822
|
(lambda : set_meta_uses_enum(meta_with_subtypes(), True)),
|
|
2821
|
-
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.
|
|
2823
|
+
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.is_empty(rt)),
|
|
2822
2824
|
(lambda : set_meta_uses_node(meta_with_subtypes(), True)),
|
|
2823
2825
|
(lambda : meta_with_subtypes()))))
|
|
2824
2826
|
|
|
@@ -2836,7 +2838,7 @@ def extend_meta_for_type(top_level: bool, is_term_annot: bool, typ: hydra.core.T
|
|
|
2836
2838
|
|
|
2837
2839
|
case hydra.core.TypeRecord(value=rt2):
|
|
2838
2840
|
has_annotated = Lazy((lambda : hydra.overlay.python.lib.lists.foldl((lambda b, ft: hydra.overlay.python.lib.logic.or_(b, hydra.annotations.has_type_description(ft.type))), False, rt2)))
|
|
2839
|
-
meta1 = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
2841
|
+
meta1 = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(rt2),
|
|
2840
2842
|
(lambda : meta_with_subtypes()),
|
|
2841
2843
|
(lambda : set_meta_uses_dataclass(meta_with_subtypes(), True)))))
|
|
2842
2844
|
return hydra.overlay.python.lib.logic.if_else(has_annotated(), (lambda : set_meta_uses_annotated(meta1(), True)), (lambda : meta1()))
|
|
@@ -2989,14 +2991,14 @@ def extend_meta_for_term(top_level: bool, meta0: hydra.python.environment.Python
|
|
|
2989
2991
|
return hydra.overlay.python.lib.eithers.either((lambda _: set_meta_uses_left(meta_with_cast(), True)), (lambda _: set_meta_uses_right(meta_with_cast(), True)), e)
|
|
2990
2992
|
|
|
2991
2993
|
case hydra.core.TermLambda(value=lam):
|
|
2992
|
-
return hydra.overlay.python.lib.optionals.
|
|
2994
|
+
return hydra.overlay.python.lib.optionals.match(lam.domain,
|
|
2993
2995
|
(lambda : meta),
|
|
2994
2996
|
(lambda dom: hydra.overlay.python.lib.logic.if_else(top_level, (lambda : extend_meta_for_type(True, False, dom, meta)), (lambda : meta))))
|
|
2995
2997
|
|
|
2996
2998
|
case hydra.core.TermLet(value=lt):
|
|
2997
2999
|
bindings = lt.bindings
|
|
2998
3000
|
return hydra.overlay.python.lib.lists.foldl((
|
|
2999
|
-
for_binding := Lazy((lambda : (lambda m, b: hydra.overlay.python.lib.optionals.
|
|
3001
|
+
for_binding := Lazy((lambda : (lambda m, b: hydra.overlay.python.lib.optionals.match(b.type_scheme,
|
|
3000
3002
|
(lambda : m),
|
|
3001
3003
|
(lambda ts: (
|
|
3002
3004
|
term1 := Lazy((lambda : b.term)),
|
|
@@ -3018,7 +3020,7 @@ def extend_meta_for_term(top_level: bool, meta0: hydra.python.environment.Python
|
|
|
3018
3020
|
return set_meta_uses_frozen_set(meta, True)
|
|
3019
3021
|
|
|
3020
3022
|
case hydra.core.TermOptional(value=m):
|
|
3021
|
-
return hydra.overlay.python.lib.optionals.
|
|
3023
|
+
return hydra.overlay.python.lib.optionals.match(m, (lambda : set_meta_uses_nothing(meta, True)), (lambda _: set_meta_uses_just(meta, True)))
|
|
3022
3024
|
|
|
3023
3025
|
case hydra.core.TermInject():
|
|
3024
3026
|
return set_meta_uses_cast(True, meta)
|
|
@@ -3110,7 +3112,7 @@ def gather_metadata(overlay_subs: Set[str], focus_ns: hydra.packaging.ModuleName
|
|
|
3110
3112
|
match def_:
|
|
3111
3113
|
case hydra.packaging.DefinitionTerm(value=term_def):
|
|
3112
3114
|
term = term_def.body
|
|
3113
|
-
typ = Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
3115
|
+
typ = Lazy((lambda : hydra.overlay.python.lib.optionals.match(term_def.signature,
|
|
3114
3116
|
(lambda : cast(hydra.core.Type, hydra.core.TypeVariable(hydra.core.Name("hydra.core.Unit")))),
|
|
3115
3117
|
(lambda sig: hydra.scoping.term_signature_to_type_scheme(sig).body))))
|
|
3116
3118
|
meta2 = Lazy((lambda : extend_meta_for_type(True, True, typ(), meta)))
|
|
@@ -3126,7 +3128,7 @@ def gather_metadata(overlay_subs: Set[str], focus_ns: hydra.packaging.ModuleName
|
|
|
3126
3128
|
result = Lazy((lambda : hydra.overlay.python.lib.lists.foldl((lambda x1, x2: add_def(x1, x2)), start(), defs)))
|
|
3127
3129
|
tvars = result().type_variables
|
|
3128
3130
|
result2 = Lazy((lambda : set_meta_uses_cast(True, set_meta_uses_lru_cache(True, result()))))
|
|
3129
|
-
return set_meta_uses_type_var(result2(), hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.
|
|
3131
|
+
return set_meta_uses_type_var(result2(), hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.is_empty(tvars)))
|
|
3130
3132
|
|
|
3131
3133
|
# The target Python version for code generation.
|
|
3132
3134
|
target_python_version = hydra.python.utils.target_python_version
|
|
@@ -3153,7 +3155,7 @@ def is_type_module_check(defs: Sequence[hydra.packaging.Definition]) -> bool:
|
|
|
3153
3155
|
|
|
3154
3156
|
case _:
|
|
3155
3157
|
return False
|
|
3156
|
-
return hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.
|
|
3158
|
+
return hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.is_empty(hydra.overlay.python.lib.lists.filter((lambda d: _hoist_hydra_python_coder_is_type_module_check_1(d)), defs)))
|
|
3157
3159
|
|
|
3158
3160
|
def module_domain_imports(namespaces: hydra.util.ModuleNames[hydra.python.syntax.DottedName]) -> Sequence[hydra.python.syntax.ImportStatement]:
|
|
3159
3161
|
r"""Generate domain import statements from namespace mappings."""
|
|
@@ -3213,7 +3215,7 @@ def module_standard_imports(meta: hydra.python.environment.PythonModuleMetadata)
|
|
|
3213
3215
|
simplified = Lazy((lambda : hydra.overlay.python.lib.optionals.givens(hydra.overlay.python.lib.lists.map((lambda p: (
|
|
3214
3216
|
mod_name := Lazy((lambda : hydra.overlay.python.lib.pairs.first(p))),
|
|
3215
3217
|
symbols := Lazy((lambda : hydra.overlay.python.lib.optionals.givens(hydra.overlay.python.lib.pairs.second(p)))),
|
|
3216
|
-
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
3218
|
+
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(symbols.get()),
|
|
3217
3219
|
(lambda : None_()),
|
|
3218
3220
|
(lambda : Given((mod_name.get(), symbols.get())))))[2]),
|
|
3219
3221
|
pairs()))))
|
|
@@ -3309,7 +3311,7 @@ defs0: Sequence[hydra.packaging.Definition]) -> Either[hydra.errors.Error, hydra
|
|
|
3309
3311
|
(lambda : set_meta_uses_type_alias(meta2.get(), True)),
|
|
3310
3312
|
(lambda : meta2.get())))),
|
|
3311
3313
|
namespaces := Lazy((lambda : meta0().namespaces)),
|
|
3312
|
-
comment_stmts := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
3314
|
+
comment_stmts := Lazy((lambda : hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.optionals.map(hydra.formatting.normalize_comment, hydra.overlay.python.lib.optionals.bind(mod.metadata, (lambda em: em.description))),
|
|
3313
3315
|
(lambda : ConsList.of()),
|
|
3314
3316
|
(lambda c: ConsList.of(hydra.python.utils.comment_statement(c)))))),
|
|
3315
3317
|
import_stmts := Lazy((lambda : module_imports(namespaces.get(), meta.get()))),
|
|
@@ -3318,7 +3320,7 @@ defs0: Sequence[hydra.packaging.Definition]) -> Either[hydra.errors.Error, hydra
|
|
|
3318
3320
|
(lambda : hydra.overlay.python.lib.sets.empty())))),
|
|
3319
3321
|
tvar_stmts := Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda tv: tvar_statement(hydra.python.names.encode_type_variable(tv))),
|
|
3320
3322
|
hydra.overlay.python.lib.sets.to_list(tvars.get())))),
|
|
3321
|
-
body := Lazy((lambda : hydra.overlay.python.lib.lists.filter((lambda group: hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.
|
|
3323
|
+
body := Lazy((lambda : hydra.overlay.python.lib.lists.filter((lambda group: hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.is_empty(group))),
|
|
3322
3324
|
hydra.overlay.python.lib.lists.concat(ConsList.of(ConsList.of(comment_stmts.get(), import_stmts.get(), tvar_stmts.get()), def_stmts))))),
|
|
3323
3325
|
Right(hydra.python.syntax.Module(body.get())))[8]))))
|
|
3324
3326
|
|
|
@@ -50,7 +50,7 @@ def overlay_python_module_aliases() -> Mapping[hydra.packaging.ModuleName, str]:
|
|
|
50
50
|
def encode_namespace_string_with_overrides(overlay_subs: Set[str], ns_val: hydra.packaging.ModuleName) -> str:
|
|
51
51
|
r"""Convert a ModuleName to its Python dotted import string, routing overlay modules to hydra.overlay.python.*."""
|
|
52
52
|
|
|
53
|
-
return hydra.overlay.python.lib.optionals.
|
|
53
|
+
return hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.logic.and_(hydra.overlay.python.lib.equality.equal(hydra.overlay.python.lib.lists.length(hydra.overlay.python.lib.strings.split_on(".", ns_val.value)), 3),
|
|
54
54
|
hydra.overlay.python.lib.equality.equal(hydra.overlay.python.lib.lists.take(2, hydra.overlay.python.lib.strings.split_on(".", ns_val.value)),
|
|
55
55
|
ConsList.of("hydra", "lib"))),
|
|
56
56
|
hydra.overlay.python.lib.sets.member(hydra.overlay.python.lib.strings.join(".", hydra.overlay.python.lib.lists.drop(2, hydra.overlay.python.lib.strings.split_on(".", ns_val.value))),
|
|
@@ -89,10 +89,10 @@ name: hydra.core.Name) -> hydra.python.syntax.Name:
|
|
|
89
89
|
def py_ns(ns_val: hydra.packaging.ModuleName) -> str:
|
|
90
90
|
return encode_namespace_string_with_overrides(env.overlay_subs, ns_val)
|
|
91
91
|
return hydra.overlay.python.lib.logic.if_else(is_qualified,
|
|
92
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
92
|
+
(lambda : hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.maps.lookup(name, bound_vars()),
|
|
93
93
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(mns, Given(focus_ns())),
|
|
94
94
|
(lambda : hydra.python.syntax.Name(hydra.overlay.python.lib.logic.if_else(use_future_annotations, (lambda : py_local()), (lambda : hydra.python.serde.escape_python_string(True, py_local()))))),
|
|
95
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
95
|
+
(lambda : hydra.overlay.python.lib.optionals.match(mns,
|
|
96
96
|
(lambda : hydra.python.syntax.Name(py_local())),
|
|
97
97
|
(lambda ns_val: hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2(py_ns(ns_val), hydra.overlay.python.lib.strings.concat2(".", py_local())))))))),
|
|
98
98
|
(lambda n: n))),
|
|
@@ -120,10 +120,10 @@ def encode_name_qualified(env: hydra.python.environment.PythonEnvironment, name:
|
|
|
120
120
|
local = qual_name().local
|
|
121
121
|
def py_ns(ns_val: hydra.packaging.ModuleName) -> str:
|
|
122
122
|
return encode_namespace_string_with_overrides(env.overlay_subs, ns_val)
|
|
123
|
-
return hydra.overlay.python.lib.optionals.
|
|
123
|
+
return hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.maps.lookup(name, bound_vars()),
|
|
124
124
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(mns, Given(focus_ns())),
|
|
125
125
|
(lambda : hydra.python.syntax.Name(hydra.overlay.python.lib.logic.if_else(use_future_annotations, (lambda : local), (lambda : hydra.python.serde.escape_python_string(True, local))))),
|
|
126
|
-
(lambda : hydra.overlay.python.lib.optionals.
|
|
126
|
+
(lambda : hydra.overlay.python.lib.optionals.match(mns,
|
|
127
127
|
(lambda : hydra.python.syntax.Name(sanitize_python_name(local))),
|
|
128
128
|
(lambda ns_val: hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2(py_ns(ns_val), hydra.overlay.python.lib.strings.concat2(".", sanitize_python_name(local))))))))),
|
|
129
129
|
(lambda n: n))
|
|
@@ -167,7 +167,7 @@ def variable_reference(conv: hydra.util.CaseConvention, quoted: bool, env: hydra
|
|
|
167
167
|
focus_pair = Lazy((lambda : namespaces.focus))
|
|
168
168
|
focus_ns = Lazy((lambda : hydra.overlay.python.lib.pairs.first(focus_pair())))
|
|
169
169
|
mns = Lazy((lambda : hydra.names.module_name_of(name)))
|
|
170
|
-
same_namespace = Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
170
|
+
same_namespace = Lazy((lambda : hydra.overlay.python.lib.optionals.match(mns(), (lambda : False), (lambda ns: hydra.overlay.python.lib.equality.equal(ns, focus_ns())))))
|
|
171
171
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.and_(quoted, same_namespace()),
|
|
172
172
|
(lambda : cast(hydra.python.syntax.Expression,
|
|
173
173
|
hydra.python.syntax.ExpressionSimple(hydra.python.syntax.Disjunction(ConsList.of(hydra.python.syntax.Conjunction(ConsList.of(cast(hydra.python.syntax.Inversion,
|
|
@@ -10,6 +10,7 @@ from hydra.overlay.python.util import ConsList, Lazy
|
|
|
10
10
|
from typing import cast
|
|
11
11
|
import hydra.constants
|
|
12
12
|
import hydra.core
|
|
13
|
+
import hydra.formatting
|
|
13
14
|
import hydra.names
|
|
14
15
|
import hydra.overlay.python.lib.equality
|
|
15
16
|
import hydra.overlay.python.lib.lists
|
|
@@ -88,13 +89,13 @@ def number_to_expr(num: hydra.python.syntax.Number) -> hydra.ast.Expr:
|
|
|
88
89
|
|
|
89
90
|
match num:
|
|
90
91
|
case hydra.python.syntax.NumberFloat(value=f):
|
|
91
|
-
return hydra.serialization.cst(python_float_literal_text(hydra.overlay.python.lib.literals.
|
|
92
|
+
return hydra.serialization.cst(python_float_literal_text(hydra.overlay.python.lib.literals.print_float64(f)))
|
|
92
93
|
|
|
93
94
|
case hydra.python.syntax.NumberImaginary(value=f2):
|
|
94
|
-
return hydra.serialization.cst(hydra.overlay.python.lib.strings.concat2(python_float_literal_text(hydra.overlay.python.lib.literals.
|
|
95
|
+
return hydra.serialization.cst(hydra.overlay.python.lib.strings.concat2(python_float_literal_text(hydra.overlay.python.lib.literals.print_float64(f2)), "j"))
|
|
95
96
|
|
|
96
97
|
case hydra.python.syntax.NumberInteger(value=i):
|
|
97
|
-
return hydra.serialization.cst(hydra.overlay.python.lib.literals.
|
|
98
|
+
return hydra.serialization.cst(hydra.overlay.python.lib.literals.print_bigint(i))
|
|
98
99
|
|
|
99
100
|
case _:
|
|
100
101
|
raise AssertionError("Unreachable: all variants handled")
|
|
@@ -136,7 +137,7 @@ def string_to_expr(s: hydra.python.syntax.String) -> hydra.ast.Expr:
|
|
|
136
137
|
r"""Serialize a Python string literal."""
|
|
137
138
|
|
|
138
139
|
content = s.value
|
|
139
|
-
prefix = Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
140
|
+
prefix = Lazy((lambda : hydra.overlay.python.lib.optionals.match(s.prefix, (lambda : ""), (lambda x1: string_prefix_to_text(x1)))))
|
|
140
141
|
style = s.quote_style
|
|
141
142
|
match style:
|
|
142
143
|
case hydra.python.syntax.QuoteStyle.SINGLE:
|
|
@@ -273,7 +274,7 @@ def comparison_to_expr(cmp: hydra.python.syntax.Comparison) -> hydra.ast.Expr:
|
|
|
273
274
|
|
|
274
275
|
lhs = cmp.lhs
|
|
275
276
|
rhs = cmp.rhs
|
|
276
|
-
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
277
|
+
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(rhs),
|
|
277
278
|
(lambda : bitwise_or_to_expr(lhs)),
|
|
278
279
|
(lambda : hydra.serialization.space_sep(hydra.overlay.python.lib.lists.cons(bitwise_or_to_expr(lhs), hydra.overlay.python.lib.lists.map((lambda x1: compare_op_bitwise_or_pair_to_expr(x1)), rhs)))))
|
|
279
280
|
|
|
@@ -759,7 +760,7 @@ def import_from_as_name_to_expr(ifan: hydra.python.syntax.ImportFromAsName) -> h
|
|
|
759
760
|
|
|
760
761
|
name = ifan.name
|
|
761
762
|
alias = ifan.as_
|
|
762
|
-
return hydra.overlay.python.lib.optionals.
|
|
763
|
+
return hydra.overlay.python.lib.optionals.match(alias,
|
|
763
764
|
(lambda : name_to_expr(name)),
|
|
764
765
|
(lambda a: hydra.serialization.space_sep(ConsList.of(name_to_expr(name), hydra.serialization.cst("as"), name_to_expr(a)))))
|
|
765
766
|
|
|
@@ -881,7 +882,7 @@ def type_alias_to_expr(ta: hydra.python.syntax.TypeAlias) -> hydra.ast.Expr:
|
|
|
881
882
|
tparams = ta.type_params
|
|
882
883
|
expr = ta.expression
|
|
883
884
|
alias = Lazy((lambda : hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(name_to_expr(name)),
|
|
884
|
-
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
885
|
+
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(tparams),
|
|
885
886
|
(lambda : None_()),
|
|
886
887
|
(lambda : Given(hydra.serialization.bracket_list(hydra.serialization.inline_style, hydra.overlay.python.lib.lists.map((lambda x1: type_parameter_to_expr(x1)), tparams))))))))))
|
|
887
888
|
return hydra.serialization.space_sep(ConsList.of(hydra.serialization.cst("type"), alias(), hydra.serialization.cst("="), expression_to_expr(expr)))
|
|
@@ -1157,7 +1158,7 @@ def to_python_comments(doc_: str) -> str:
|
|
|
1157
1158
|
hydra.overlay.python.lib.lists.map((lambda line: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(line, ""),
|
|
1158
1159
|
(lambda : "#"),
|
|
1159
1160
|
(lambda : hydra.overlay.python.lib.strings.concat2("# ", line)))),
|
|
1160
|
-
hydra.
|
|
1161
|
+
hydra.formatting.lines(hydra.print.docs.render_doc_string_with((lambda x1: python_doc_entity_ref(x1)), doc_))))))
|
|
1161
1162
|
|
|
1162
1163
|
def annotated_statement_to_expr(as_: hydra.python.syntax.AnnotatedStatement) -> hydra.ast.Expr:
|
|
1163
1164
|
r"""Serialize an annotated statement (with optional doc comment)."""
|
|
@@ -1248,7 +1249,7 @@ def function_def_raw_to_expr(fdr: hydra.python.syntax.FunctionDefRaw) -> hydra.a
|
|
|
1248
1249
|
ret_type = fdr.return_type
|
|
1249
1250
|
block = fdr.block
|
|
1250
1251
|
async_kw = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(async_, (lambda : Given(hydra.serialization.cst("async"))), (lambda : None_()))))
|
|
1251
|
-
tparam_part = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
1252
|
+
tparam_part = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(tparams),
|
|
1252
1253
|
(lambda : None_()),
|
|
1253
1254
|
(lambda : Given(hydra.serialization.bracket_list(hydra.serialization.inline_style, hydra.overlay.python.lib.lists.map((lambda x1: type_parameter_to_expr(x1)), tparams)))))))
|
|
1254
1255
|
param_part = Lazy((lambda : hydra.overlay.python.lib.optionals.map((lambda x1: parameters_to_expr(x1)), params)))
|
|
@@ -49,7 +49,7 @@ def generate_python_test_case(group_path: Sequence[str], tcm: hydra.testing.Test
|
|
|
49
49
|
case hydra.testing.TestCaseUniversal(value=ucase):
|
|
50
50
|
actual_ = Lazy((lambda : ucase.actual(None)))
|
|
51
51
|
expected_ = Lazy((lambda : ucase.expected(None)))
|
|
52
|
-
full_name = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
52
|
+
full_name = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(group_path),
|
|
53
53
|
(lambda : name_),
|
|
54
54
|
(lambda : hydra.overlay.python.lib.strings.join("__", hydra.overlay.python.lib.lists.concat2(group_path, ConsList.of(name_)))))))
|
|
55
55
|
formatted_name = Lazy((lambda : format_python_test_name(full_name())))
|
|
@@ -113,14 +113,14 @@ def py_name_to_py_primary(name: hydra.python.syntax.Name) -> hydra.python.syntax
|
|
|
113
113
|
def annotated_expression(mcomment: Optional[str], expr: hydra.python.syntax.Expression) -> hydra.python.syntax.Expression:
|
|
114
114
|
r"""Annotate an expression with an optional comment using Annotated[]."""
|
|
115
115
|
|
|
116
|
-
return hydra.overlay.python.lib.optionals.
|
|
116
|
+
return hydra.overlay.python.lib.optionals.match(mcomment,
|
|
117
117
|
(lambda : expr),
|
|
118
118
|
(lambda c: py_primary_to_py_expression(primary_with_expression_slices(py_name_to_py_primary(hydra.python.syntax.Name("Annotated")), ConsList.of(expr, double_quoted_string(c))))))
|
|
119
119
|
|
|
120
120
|
def annotated_statement(mcomment: Optional[str], stmt: hydra.python.syntax.Statement) -> hydra.python.syntax.Statement:
|
|
121
121
|
r"""Annotate a statement with an optional comment."""
|
|
122
122
|
|
|
123
|
-
return hydra.overlay.python.lib.optionals.
|
|
123
|
+
return hydra.overlay.python.lib.optionals.match(mcomment,
|
|
124
124
|
(lambda : stmt),
|
|
125
125
|
(lambda c: cast(hydra.python.syntax.Statement, hydra.python.syntax.StatementAnnotated(hydra.python.syntax.AnnotatedStatement(c, stmt)))))
|
|
126
126
|
|
|
@@ -229,7 +229,7 @@ def decode_py_comparison_to_py_await_primary(c: hydra.python.syntax.Comparison)
|
|
|
229
229
|
|
|
230
230
|
case _:
|
|
231
231
|
return None_()
|
|
232
|
-
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.
|
|
232
|
+
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.is_empty(rhs)),
|
|
233
233
|
(lambda : None_()),
|
|
234
234
|
(lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.optionals.is_given(or_lhs),
|
|
235
235
|
(lambda : None_()),
|
|
@@ -306,10 +306,10 @@ def get_item_params() -> hydra.python.syntax.Parameters:
|
|
|
306
306
|
def indented_block(mcomment: Optional[str], stmts: Sequence[Sequence[hydra.python.syntax.Statement]]) -> hydra.python.syntax.Block:
|
|
307
307
|
r"""Create an indented block with optional comment."""
|
|
308
308
|
|
|
309
|
-
comment_group = Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
310
|
-
groups = Lazy((lambda : hydra.overlay.python.lib.lists.filter((lambda g: hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.
|
|
309
|
+
comment_group = Lazy((lambda : hydra.overlay.python.lib.optionals.match(mcomment, (lambda : ConsList.of()), (lambda s: ConsList.of(comment_statement(s))))))
|
|
310
|
+
groups = Lazy((lambda : hydra.overlay.python.lib.lists.filter((lambda g: hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.is_empty(g))),
|
|
311
311
|
hydra.overlay.python.lib.lists.cons(comment_group(), stmts))))
|
|
312
|
-
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
312
|
+
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(groups()),
|
|
313
313
|
(lambda : cast(hydra.python.syntax.Block,
|
|
314
314
|
hydra.python.syntax.BlockIndented(ConsList.of(ConsList.of(cast(hydra.python.syntax.Statement,
|
|
315
315
|
hydra.python.syntax.StatementSimple(ConsList.of(py_expression_to_py_simple_statement(py_atom_to_py_expression(cast(hydra.python.syntax.Atom, hydra.python.syntax.AtomEllipsis()))))))))))),
|
|
@@ -354,11 +354,11 @@ def or_expression(prims: Sequence[hydra.python.syntax.Primary]) -> hydra.python.
|
|
|
354
354
|
r"""Build an or-expression from multiple primaries."""
|
|
355
355
|
|
|
356
356
|
def build(prev: Optional[hydra.python.syntax.BitwiseOr], ps: Sequence[hydra.python.syntax.Primary]) -> hydra.python.syntax.BitwiseOr:
|
|
357
|
-
return hydra.overlay.python.lib.optionals.
|
|
357
|
+
return hydra.overlay.python.lib.optionals.match(hydra.overlay.python.lib.lists.uncons(ps),
|
|
358
358
|
(lambda : hydra.python.syntax.BitwiseOr(prev,
|
|
359
359
|
py_primary_to_py_bitwise_xor(cast(hydra.python.syntax.Primary,
|
|
360
360
|
hydra.python.syntax.PrimarySimple(cast(hydra.python.syntax.Atom, hydra.python.syntax.AtomEllipsis())))))),
|
|
361
|
-
(lambda p: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
361
|
+
(lambda p: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(hydra.overlay.python.lib.pairs.second(p)),
|
|
362
362
|
(lambda : hydra.python.syntax.BitwiseOr(prev, py_primary_to_py_bitwise_xor(hydra.overlay.python.lib.pairs.first(p)))),
|
|
363
363
|
(lambda : build(Given(hydra.python.syntax.BitwiseOr(prev, py_primary_to_py_bitwise_xor(hydra.overlay.python.lib.pairs.first(p)))),
|
|
364
364
|
hydra.overlay.python.lib.pairs.second(p))))))
|
|
@@ -419,7 +419,7 @@ def py_expression_to_disjunction(e: hydra.python.syntax.Expression) -> hydra.pyt
|
|
|
419
419
|
def py_expression_to_py_primary(e: hydra.python.syntax.Expression) -> hydra.python.syntax.Primary:
|
|
420
420
|
r"""Extracts the primary from an expression, or wraps it in parentheses if the expression does not contain a primary."""
|
|
421
421
|
|
|
422
|
-
return hydra.overlay.python.lib.optionals.
|
|
422
|
+
return hydra.overlay.python.lib.optionals.match(decode_py_expression_to_py_primary(e),
|
|
423
423
|
(lambda : cast(hydra.python.syntax.Primary,
|
|
424
424
|
hydra.python.syntax.PrimarySimple(cast(hydra.python.syntax.Atom,
|
|
425
425
|
hydra.python.syntax.AtomGroup(cast(hydra.python.syntax.Group,
|
|
@@ -595,7 +595,7 @@ extra_stmts: Sequence[hydra.python.syntax.Statement]) -> Sequence[hydra.python.s
|
|
|
595
595
|
ConsList.of())))))))))))),
|
|
596
596
|
indented_block(None_(), ConsList.of(ConsList.of(get_item_method())))))))
|
|
597
597
|
doc_stmt = Lazy((lambda : py_expression_to_py_statement(triple_quoted_string(doc_string()))))
|
|
598
|
-
body_groups = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.
|
|
598
|
+
body_groups = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.is_empty(extra_stmts),
|
|
599
599
|
(lambda : (
|
|
600
600
|
pass_stmt := Lazy((lambda : py_simple_statement_to_py_statement(cast(hydra.python.syntax.SimpleStatement, hydra.python.syntax.SimpleStatementPass())))),
|
|
601
601
|
ConsList.of(ConsList.of(doc_stmt()), ConsList.of(pass_stmt.get())))[1]),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|