hydra-python 0.17.4__tar.gz → 0.17.5__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.5}/PKG-INFO +3 -3
- {hydra_python-0.17.4 → hydra_python-0.17.5}/build/main/digest.json +20 -20
- {hydra_python-0.17.4 → hydra_python-0.17.5}/pyproject.toml +2 -2
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/python/coder.py +37 -37
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/python/names.py +6 -6
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/python/serde.py +4 -3
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/python/utils.py +5 -5
- {hydra_python-0.17.4 → hydra_python-0.17.5}/.gitignore +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/LICENSE +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/NOTICE +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/README.md +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/dsl/python/environment.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/dsl/python/names.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/dsl/python/syntax.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/dsl/python/utils.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/python/environment.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/python/language.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/python/pyproject.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/python/syntax.py +0 -0
- {hydra_python-0.17.4 → hydra_python-0.17.5}/src/main/python/hydra/python/testing.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.5
|
|
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.5
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
|
|
15
15
|
# Hydra-Python
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"digestFormatVersion": 2,
|
|
3
3
|
"moduleFormatVersion": 1,
|
|
4
|
-
"generator": "
|
|
4
|
+
"generator": "9de7bd43d8cafa93",
|
|
5
5
|
"generation": {
|
|
6
|
-
"generatorId": "
|
|
6
|
+
"generatorId": "9de7bd43d8cafa93",
|
|
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.4",
|
|
10
|
+
"revision": "9571823830-dirty",
|
|
11
|
+
"timestamp": "2026-08-19T17:44:59Z"},
|
|
12
|
+
"selfHash": "f628802be436ebb317632a9429323b63f0ae5045bda0ba24aa263ccf2092e014",
|
|
13
|
+
"dependencyHashes": [{"key": "hydra-kernel", "value": "5b5813a6dabbc89ed0e4ddd918744636da84f3542d7961284c423aea53629b02"}],
|
|
14
14
|
"inputs": [
|
|
15
15
|
{
|
|
16
16
|
"key": "hydra.python.coder",
|
|
17
|
-
"value": {"kind": "other", "hash": "
|
|
17
|
+
"value": {"kind": "other", "hash": "0b1e385015be90731b3a461486eec1c2ab2448e1643f3a9e4f1f7427ec0e085a"}},
|
|
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": "83e48906bdec70d3d0d427c0e1b02b5e4d08bb172d3f85be13992ef4c1120859"}},
|
|
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": "113853c870177388fbcc53800768d872fae34fdbfd1a0e2f30d2b2aefb966451"}},
|
|
39
39
|
{
|
|
40
40
|
"key": "hydra.python.utils",
|
|
41
|
-
"value": {"kind": "other", "hash": "
|
|
41
|
+
"value": {"kind": "other", "hash": "f480bc8a4c39e62ea073357517964a2175e582fd220de0fbc1bc27b9b108d327"}},
|
|
42
42
|
{
|
|
43
43
|
"key": "jsonContent:hydra/dsl/python/environment.json",
|
|
44
44
|
"value": {"kind": "other", "hash": "684965cea67ad57d492b50f408c6575f679b073c5de5e76826fb0941da86ec21"}},
|
|
@@ -53,7 +53,7 @@
|
|
|
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": "e2f66b5c16393d8050923aab1f832f430334e4bddfc101f4cebc1f158daee01d"}},
|
|
57
57
|
{
|
|
58
58
|
"key": "jsonContent:hydra/python/environment.json",
|
|
59
59
|
"value": {"kind": "other", "hash": "889380dd3664c763437475b2e5146b38f865f4a20a308332633a33a4d038fce1"}},
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"value": {"kind": "other", "hash": "221e68d68030945db181fdd079be4ff619cb4cd1ad5d4b72b4e70f2aa1bd5230"}},
|
|
63
63
|
{
|
|
64
64
|
"key": "jsonContent:hydra/python/names.json",
|
|
65
|
-
"value": {"kind": "other", "hash": "
|
|
65
|
+
"value": {"kind": "other", "hash": "afaa99c99874efa5e02a10973651a7a74ab1089feedb9de0f8a74904a8ec4eb7"}},
|
|
66
66
|
{
|
|
67
67
|
"key": "jsonContent:hydra/python/pyproject.json",
|
|
68
68
|
"value": {"kind": "other", "hash": "c94de46f1615e6e82d2f706d01ef04293373f6241a9a42882bb394d51b4f7f53"}},
|
|
69
69
|
{
|
|
70
70
|
"key": "jsonContent:hydra/python/serde.json",
|
|
71
|
-
"value": {"kind": "other", "hash": "
|
|
71
|
+
"value": {"kind": "other", "hash": "e987b94392abfc72cedc08d2e6b8a4528479a9023c9eff636f8980e9af6e6cfb"}},
|
|
72
72
|
{
|
|
73
73
|
"key": "jsonContent:hydra/python/syntax.json",
|
|
74
74
|
"value": {"kind": "other", "hash": "8dc3a26ac927fa338b273c9deee6317906977a2deec4c2df1e44ff0bbe0a64cd"}},
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"value": {"kind": "other", "hash": "9c75b534004194396935b1dd3331bae4d8d5cbb31c3959fa3794dda00960c09a"}},
|
|
78
78
|
{
|
|
79
79
|
"key": "jsonContent:hydra/python/utils.json",
|
|
80
|
-
"value": {"kind": "other", "hash": "
|
|
80
|
+
"value": {"kind": "other", "hash": "0ef54f39243803add5f5634d67bf8c949d89159b3fc1c4ff82d9cb0bf829f4b9"}},
|
|
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": "eb662817f2e3390220a06eb6eda9cc7adce67d3e22b47f3e2823ab273d688af6"}},
|
|
100
100
|
{
|
|
101
101
|
"key": "hydra/python/environment.py",
|
|
102
102
|
"value": {"kind": "targetFile", "hash": "1036eb9d285ba3e98c85095820f2e77900334340c9f0223fd4dfd6b3e847f4df"}},
|
|
@@ -105,13 +105,13 @@
|
|
|
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": "a783457c64ea85769cd2ab757bd429be4d0c7333ab5765b0c04f3b0bf86b1e80"}},
|
|
115
115
|
{
|
|
116
116
|
"key": "hydra/python/syntax.py",
|
|
117
117
|
"value": {"kind": "targetFile", "hash": "24a72af882b47d80cc930f16f51a3e9c1a71c9d8da47a921829f40e847459fca"}},
|
|
@@ -120,4 +120,4 @@
|
|
|
120
120
|
"value": {"kind": "targetFile", "hash": "069c706253e0c41695c8becd42c27c84b7f6ac54b14be14975757ff09416ba92"}},
|
|
121
121
|
{
|
|
122
122
|
"key": "hydra/python/utils.py",
|
|
123
|
-
"value": {"kind": "targetFile", "hash": "
|
|
123
|
+
"value": {"kind": "targetFile", "hash": "b53dbe52de14f67d6a3c74d8f6bd7051fbaa65dbf686362565bb5cda61f15075"}}]}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
[project]
|
|
15
15
|
name = "hydra-python"
|
|
16
|
-
version = "0.17.
|
|
16
|
+
version = "0.17.5"
|
|
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.5",
|
|
26
26
|
]
|
|
27
27
|
|
|
28
28
|
[project.urls]
|
|
@@ -339,7 +339,7 @@ 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))),
|
|
@@ -892,7 +892,7 @@ def make_simple_lambda(arity: int, lhs: hydra.python.syntax.Expression) -> hydra
|
|
|
892
892
|
r"""Wrap a bare reference to a polymorphic function in an uncurried lambda."""
|
|
893
893
|
|
|
894
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.show_int32(i)))),
|
|
895
|
-
hydra.overlay.python.lib.math.range_(1, arity))))
|
|
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,
|
|
@@ -948,7 +948,7 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
948
948
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.null(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))),
|
|
@@ -958,7 +958,7 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
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
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.show_int32(i)))),
|
|
961
|
-
hydra.overlay.python.lib.math.range_(1, num_remaining.get())))),
|
|
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,20 +981,20 @@ 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)),
|
|
@@ -1027,7 +1027,7 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
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
1032
|
as_function_ref := Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.sets.null(hydra.variables.free_variables_in_type(typ))),
|
|
1033
1033
|
(lambda : make_simple_lambda(hydra.arity.type_arity(typ), as_variable())),
|
|
@@ -1035,7 +1035,7 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
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())),
|
|
@@ -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
|
|
@@ -1236,10 +1236,10 @@ 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))),
|
|
@@ -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),
|
|
@@ -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: (
|
|
@@ -1802,9 +1802,9 @@ def encode_binding_as(cx: hydra.typing.InferenceContext, env: hydra.python.envir
|
|
|
1802
1802
|
(lambda csa: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.null(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: (
|
|
@@ -2002,7 +2002,7 @@ 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: (
|
|
@@ -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
|
|
|
@@ -2447,7 +2447,7 @@ 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.
|
|
2450
|
+
typ = Lazy((lambda : hydra.overlay.python.lib.optionals.match(td.signature,
|
|
2451
2451
|
(lambda : hydra.core.TypeScheme(ConsList.of(), cast(hydra.core.Type, hydra.core.TypeVariable(hydra.core.Name("hydra.core.Unit"))), None_())),
|
|
2452
2452
|
(lambda sig: hydra.scoping.term_signature_to_type_scheme(sig)))))
|
|
2453
2453
|
return hydra.overlay.python.lib.eithers.bind(hydra.annotations.get_term_description(cx, python_environment_get_graph(env), term),
|
|
@@ -2989,14 +2989,14 @@ def extend_meta_for_term(top_level: bool, meta0: hydra.python.environment.Python
|
|
|
2989
2989
|
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
2990
|
|
|
2991
2991
|
case hydra.core.TermLambda(value=lam):
|
|
2992
|
-
return hydra.overlay.python.lib.optionals.
|
|
2992
|
+
return hydra.overlay.python.lib.optionals.match(lam.domain,
|
|
2993
2993
|
(lambda : meta),
|
|
2994
2994
|
(lambda dom: hydra.overlay.python.lib.logic.if_else(top_level, (lambda : extend_meta_for_type(True, False, dom, meta)), (lambda : meta))))
|
|
2995
2995
|
|
|
2996
2996
|
case hydra.core.TermLet(value=lt):
|
|
2997
2997
|
bindings = lt.bindings
|
|
2998
2998
|
return hydra.overlay.python.lib.lists.foldl((
|
|
2999
|
-
for_binding := Lazy((lambda : (lambda m, b: hydra.overlay.python.lib.optionals.
|
|
2999
|
+
for_binding := Lazy((lambda : (lambda m, b: hydra.overlay.python.lib.optionals.match(b.type_scheme,
|
|
3000
3000
|
(lambda : m),
|
|
3001
3001
|
(lambda ts: (
|
|
3002
3002
|
term1 := Lazy((lambda : b.term)),
|
|
@@ -3018,7 +3018,7 @@ def extend_meta_for_term(top_level: bool, meta0: hydra.python.environment.Python
|
|
|
3018
3018
|
return set_meta_uses_frozen_set(meta, True)
|
|
3019
3019
|
|
|
3020
3020
|
case hydra.core.TermOptional(value=m):
|
|
3021
|
-
return hydra.overlay.python.lib.optionals.
|
|
3021
|
+
return hydra.overlay.python.lib.optionals.match(m, (lambda : set_meta_uses_nothing(meta, True)), (lambda _: set_meta_uses_just(meta, True)))
|
|
3022
3022
|
|
|
3023
3023
|
case hydra.core.TermInject():
|
|
3024
3024
|
return set_meta_uses_cast(True, meta)
|
|
@@ -3110,7 +3110,7 @@ def gather_metadata(overlay_subs: Set[str], focus_ns: hydra.packaging.ModuleName
|
|
|
3110
3110
|
match def_:
|
|
3111
3111
|
case hydra.packaging.DefinitionTerm(value=term_def):
|
|
3112
3112
|
term = term_def.body
|
|
3113
|
-
typ = Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
3113
|
+
typ = Lazy((lambda : hydra.overlay.python.lib.optionals.match(term_def.signature,
|
|
3114
3114
|
(lambda : cast(hydra.core.Type, hydra.core.TypeVariable(hydra.core.Name("hydra.core.Unit")))),
|
|
3115
3115
|
(lambda sig: hydra.scoping.term_signature_to_type_scheme(sig).body))))
|
|
3116
3116
|
meta2 = Lazy((lambda : extend_meta_for_type(True, True, typ(), meta)))
|
|
@@ -3309,7 +3309,7 @@ defs0: Sequence[hydra.packaging.Definition]) -> Either[hydra.errors.Error, hydra
|
|
|
3309
3309
|
(lambda : set_meta_uses_type_alias(meta2.get(), True)),
|
|
3310
3310
|
(lambda : meta2.get())))),
|
|
3311
3311
|
namespaces := Lazy((lambda : meta0().namespaces)),
|
|
3312
|
-
comment_stmts := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
3312
|
+
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
3313
|
(lambda : ConsList.of()),
|
|
3314
3314
|
(lambda c: ConsList.of(hydra.python.utils.comment_statement(c)))))),
|
|
3315
3315
|
import_stmts := Lazy((lambda : module_imports(namespaces.get(), meta.get()))),
|
|
@@ -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
|
|
@@ -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:
|
|
@@ -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
|
|
|
@@ -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)."""
|
|
@@ -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
|
|
|
@@ -306,7 +306,7 @@ 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.
|
|
309
|
+
comment_group = Lazy((lambda : hydra.overlay.python.lib.optionals.match(mcomment, (lambda : ConsList.of()), (lambda s: ConsList.of(comment_statement(s))))))
|
|
310
310
|
groups = Lazy((lambda : hydra.overlay.python.lib.lists.filter((lambda g: hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.lists.null(g))),
|
|
311
311
|
hydra.overlay.python.lib.lists.cons(comment_group(), stmts))))
|
|
312
312
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.null(groups()),
|
|
@@ -354,7 +354,7 @@ 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())))))),
|
|
@@ -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,
|
|
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
|
|
File without changes
|
|
File without changes
|