hydra-python 0.17.1__tar.gz → 0.17.3__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.1 → hydra_python-0.17.3}/.gitignore +19 -25
- hydra_python-0.17.1/README.md → hydra_python-0.17.3/PKG-INFO +31 -11
- hydra_python-0.17.1/PKG-INFO → hydra_python-0.17.3/README.md +17 -25
- {hydra_python-0.17.1 → hydra_python-0.17.3}/build/main/digest.json +22 -22
- {hydra_python-0.17.1 → hydra_python-0.17.3}/pyproject.toml +2 -2
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/python/coder.py +33 -32
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/python/names.py +5 -5
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/python/serde.py +40 -40
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/python/testing.py +15 -15
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/python/utils.py +4 -4
- {hydra_python-0.17.1 → hydra_python-0.17.3}/LICENSE +0 -0
- {hydra_python-0.17.1 → hydra_python-0.17.3}/NOTICE +0 -0
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/dsl/python/environment.py +0 -0
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/dsl/python/names.py +0 -0
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/dsl/python/syntax.py +0 -0
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/dsl/python/utils.py +0 -0
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/python/environment.py +0 -0
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/python/language.py +0 -0
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/python/pyproject.py +0 -0
- {hydra_python-0.17.1 → hydra_python-0.17.3}/src/main/python/hydra/python/syntax.py +0 -0
|
@@ -29,6 +29,7 @@ stack.yaml.lock
|
|
|
29
29
|
gradle.properties
|
|
30
30
|
/packages/hydra-java/build/
|
|
31
31
|
/heads/java/json-driver/build/
|
|
32
|
+
/heads/java/target-driver/build/
|
|
32
33
|
|
|
33
34
|
# IDEs
|
|
34
35
|
.bsp/
|
|
@@ -73,31 +74,21 @@ docs/reviews/
|
|
|
73
74
|
docs/work/
|
|
74
75
|
|
|
75
76
|
# Package distributions.
|
|
76
|
-
# dist/json/ is the source of truth (tracked).
|
|
77
|
-
#
|
|
78
|
-
#
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
-
#
|
|
83
|
-
#
|
|
84
|
-
#
|
|
85
|
-
#
|
|
86
|
-
#
|
|
87
|
-
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
dist/haskell/
|
|
91
|
-
dist/haskell/hydra-kernel/src/main/haskell/Hydra/Kernel.hs
|
|
92
|
-
dist/haskell/hydra-kernel/src/main/haskell/Hydra/Overlay/
|
|
93
|
-
# - hydra-kernel hand-written test bridge (overlaid from overlay/haskell/.../src/test/)
|
|
94
|
-
dist/haskell/hydra-kernel/src/test/haskell/Hydra/Test/TestEnv.hs
|
|
95
|
-
dist/haskell/hydra-kernel/src/test/haskell/Hydra/Test/DefaultImplGraph.hs
|
|
96
|
-
# - hydra-pg / hydra-typescript hand-written DSL helpers (overlaid from
|
|
97
|
-
# overlay/haskell/hydra-{pg,typescript}/; relocated to the
|
|
98
|
-
# Hydra.Overlay.Haskell.* namespace in #501/#556)
|
|
99
|
-
dist/haskell/hydra-pg/src/main/haskell/Hydra/Overlay/
|
|
100
|
-
dist/haskell/hydra-typescript/src/main/haskell/Hydra/Overlay/
|
|
77
|
+
# dist/json/ is the source of truth (tracked). All target-language trees,
|
|
78
|
+
# INCLUDING dist/haskell/ as of #376, are regenerated from dist/json/ and not
|
|
79
|
+
# checked in. dist/haskell/ was tracked from the 0.15 release through #376 to
|
|
80
|
+
# support bootstrapping from a fresh clone before the cold-clone seeder
|
|
81
|
+
# (heads/haskell/json-driver/) existed; that seeder now performs the same
|
|
82
|
+
# role by regenerating dist/haskell/ from the committed dist/json/ using only
|
|
83
|
+
# published Hackage coder packages — see bin/sync.sh's cold-start detection
|
|
84
|
+
# and heads/haskell/json-driver/bin/cold-seed-dist-haskell.sh. The former
|
|
85
|
+
# per-file overlay exceptions under dist/haskell/ (hydra umbrella,
|
|
86
|
+
# hydra-kernel hand-written runtime, hydra-pg/hydra-typescript DSL helpers)
|
|
87
|
+
# are subsumed by this blanket ignore; their canonical copies remain tracked
|
|
88
|
+
# under overlay/haskell/. (Hackage channel staging artifacts — the sdists and
|
|
89
|
+
# Haddock docs that prepare-release.sh / publish-hackage.sh assemble into
|
|
90
|
+
# dist/haskell/ — are likewise covered by this blanket ignore. #589.)
|
|
91
|
+
dist/haskell/
|
|
101
92
|
|
|
102
93
|
dist/clojure/
|
|
103
94
|
dist/common-lisp/
|
|
@@ -156,3 +147,6 @@ claude-hydra-messages/
|
|
|
156
147
|
# survey/ff/bootstrap watchers). These are dot-prefixed .sh under claude/;
|
|
157
148
|
# the tracked claude/ content is the .md protocol docs, never dot-.sh scripts.
|
|
158
149
|
claude/.*.sh
|
|
150
|
+
|
|
151
|
+
# Backed-up branch plan documents (not release content)
|
|
152
|
+
finalized-task-plans/
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hydra-python
|
|
3
|
+
Version: 0.17.3
|
|
4
|
+
Summary: Python support for Hydra
|
|
5
|
+
Project-URL: Homepage, https://github.com/CategoricalData/hydra
|
|
6
|
+
Project-URL: Repository, https://github.com/CategoricalData/hydra
|
|
7
|
+
Author-email: Joshua Shinavier <josh@fortytwo.net>
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: NOTICE
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
|
+
Requires-Dist: hydra-kernel==0.17.3
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
1
15
|
# Hydra-Python
|
|
2
16
|
|
|
3
17
|
This package contains the **Python coder DSL sources**: Python modules that describe
|
|
@@ -11,6 +25,12 @@ Hydra is a type-aware data transformation toolkit which aims to be highly flexib
|
|
|
11
25
|
It has its roots in graph databases and type theory, and provides APIs in Haskell, Java, Python, Scala, TypeScript, and Lisp.
|
|
12
26
|
See the main Hydra [README](https://github.com/CategoricalData/hydra) for more details.
|
|
13
27
|
|
|
28
|
+
📖 **API documentation:** Sphinx-generated API docs for the Python packages are published at the
|
|
29
|
+
[Hydra Python API index](https://categoricaldata.net/hydra/python/sphinx/)
|
|
30
|
+
(individual packages: [hydra-kernel](https://categoricaldata.net/hydra/python/sphinx/hydra-kernel/),
|
|
31
|
+
[hydra-rdf](https://categoricaldata.net/hydra/python/sphinx/hydra-rdf/),
|
|
32
|
+
[hydra-pg](https://categoricaldata.net/hydra/python/sphinx/hydra-pg/)).
|
|
33
|
+
|
|
14
34
|
## Getting started
|
|
15
35
|
|
|
16
36
|
Hydra-Python requires Python 3.12 or later.
|
|
@@ -44,7 +64,7 @@ For comprehensive documentation about Hydra's architecture and usage, see:
|
|
|
44
64
|
- **[Code Organization](https://github.com/CategoricalData/hydra/wiki/Code-organization)** -
|
|
45
65
|
The `packages/`, `heads/`, `dist/` layout
|
|
46
66
|
- **[Testing](https://github.com/CategoricalData/hydra/wiki/Testing)** -
|
|
47
|
-
|
|
67
|
+
Hydra-kernel test suite documentation
|
|
48
68
|
- **[Developer Recipes](https://github.com/CategoricalData/hydra/blob/main/docs/recipes/index.md)** -
|
|
49
69
|
Step-by-step guides
|
|
50
70
|
- **[Syncing Hydra-Python](https://github.com/CategoricalData/hydra/blob/main/docs/recipes/syncing-python.md)** -
|
|
@@ -52,15 +72,15 @@ For comprehensive documentation about Hydra's architecture and usage, see:
|
|
|
52
72
|
|
|
53
73
|
## Testing
|
|
54
74
|
|
|
55
|
-
Hydra-Python has two types of tests: the **
|
|
75
|
+
Hydra-Python has two types of tests: the **hydra-kernel test suite** (shared across all Hydra implementations)
|
|
56
76
|
and **Python-specific tests**.
|
|
57
77
|
See the [Testing wiki page](https://github.com/CategoricalData/hydra/wiki/Testing)
|
|
58
78
|
for comprehensive documentation.
|
|
59
79
|
|
|
60
|
-
###
|
|
80
|
+
### Hydra-kernel test suite
|
|
61
81
|
|
|
62
|
-
The
|
|
63
|
-
**Passing all
|
|
82
|
+
The hydra-kernel test suite (`hydra.test.testSuite`) ensures parity across all Hydra implementations.
|
|
83
|
+
**Passing all hydra-kernel test suite cases is the criterion for a true Hydra implementation.**
|
|
64
84
|
|
|
65
85
|
To run all tests (from `heads/python/`):
|
|
66
86
|
|
|
@@ -68,7 +88,7 @@ To run all tests (from `heads/python/`):
|
|
|
68
88
|
cd heads/python && pytest
|
|
69
89
|
```
|
|
70
90
|
|
|
71
|
-
To run only the
|
|
91
|
+
To run only the hydra-kernel test suite:
|
|
72
92
|
|
|
73
93
|
```bash
|
|
74
94
|
cd heads/python && pytest src/test/python/test_suite_runner.py
|
|
@@ -86,7 +106,7 @@ The test suite is generated from Hydra DSL sources and includes:
|
|
|
86
106
|
### Python-specific tests
|
|
87
107
|
|
|
88
108
|
Python-specific tests validate implementation details and Python-specific functionality.
|
|
89
|
-
These are located in `heads/python/src/test/python/` alongside the
|
|
109
|
+
These are located in `heads/python/src/test/python/` alongside the hydra-kernel test suite runner.
|
|
90
110
|
|
|
91
111
|
To run a specific test file:
|
|
92
112
|
|
|
@@ -120,10 +140,10 @@ Hydra's Python code is split across three locations
|
|
|
120
140
|
- **Python kernel overlay** ([`overlay/python/hydra-kernel/src/main/python/`](https://github.com/CategoricalData/hydra/tree/main/overlay/python/hydra-kernel/src/main/python))
|
|
121
141
|
— hand-written Python kernel runtime, overlaid onto `dist/python/hydra-kernel/`
|
|
122
142
|
by `heads/python/bin/copy-kernel-runtime.sh` so the published `hydra-kernel` wheel is self-contained
|
|
123
|
-
- `hydra/lib/` — primitive function implementations
|
|
124
|
-
- `hydra/dsl/` — DSL utilities (FrozenDict, Maybe, ...)
|
|
125
|
-
- `hydra/python/util/` — `ConsList`, `Lazy`, `PersistentMap`, `PersistentSet`
|
|
126
|
-
- `hydra/sources/libraries.py` — primitive registration
|
|
143
|
+
- `hydra/overlay/python/lib/` — primitive function implementations
|
|
144
|
+
- `hydra/overlay/python/dsl/` — DSL utilities (FrozenDict, Maybe, ...)
|
|
145
|
+
- `hydra/overlay/python/util/` — `ConsList`, `Lazy`, `PersistentMap`, `PersistentSet`
|
|
146
|
+
- `hydra/overlay/python/sources/libraries.py` — primitive registration
|
|
127
147
|
- **Python head** ([`heads/python/src/main/python/`](https://github.com/CategoricalData/hydra/tree/main/heads/python/src/main/python))
|
|
128
148
|
— bootstrap layer above the kernel (`bootstrap.py`, `generation.py`, the `hydra.python` coder
|
|
129
149
|
package). `pyproject.toml` lives in `heads/python/`.
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: hydra-python
|
|
3
|
-
Version: 0.17.1
|
|
4
|
-
Summary: Python support for Hydra
|
|
5
|
-
Project-URL: Homepage, https://github.com/CategoricalData/hydra
|
|
6
|
-
Project-URL: Repository, https://github.com/CategoricalData/hydra
|
|
7
|
-
Author-email: Joshua Shinavier <josh@fortytwo.net>
|
|
8
|
-
License: Apache-2.0
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
License-File: NOTICE
|
|
11
|
-
Requires-Python: >=3.12
|
|
12
|
-
Requires-Dist: hydra-kernel==0.17.1
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
|
|
15
1
|
# Hydra-Python
|
|
16
2
|
|
|
17
3
|
This package contains the **Python coder DSL sources**: Python modules that describe
|
|
@@ -25,6 +11,12 @@ Hydra is a type-aware data transformation toolkit which aims to be highly flexib
|
|
|
25
11
|
It has its roots in graph databases and type theory, and provides APIs in Haskell, Java, Python, Scala, TypeScript, and Lisp.
|
|
26
12
|
See the main Hydra [README](https://github.com/CategoricalData/hydra) for more details.
|
|
27
13
|
|
|
14
|
+
📖 **API documentation:** Sphinx-generated API docs for the Python packages are published at the
|
|
15
|
+
[Hydra Python API index](https://categoricaldata.net/hydra/python/sphinx/)
|
|
16
|
+
(individual packages: [hydra-kernel](https://categoricaldata.net/hydra/python/sphinx/hydra-kernel/),
|
|
17
|
+
[hydra-rdf](https://categoricaldata.net/hydra/python/sphinx/hydra-rdf/),
|
|
18
|
+
[hydra-pg](https://categoricaldata.net/hydra/python/sphinx/hydra-pg/)).
|
|
19
|
+
|
|
28
20
|
## Getting started
|
|
29
21
|
|
|
30
22
|
Hydra-Python requires Python 3.12 or later.
|
|
@@ -58,7 +50,7 @@ For comprehensive documentation about Hydra's architecture and usage, see:
|
|
|
58
50
|
- **[Code Organization](https://github.com/CategoricalData/hydra/wiki/Code-organization)** -
|
|
59
51
|
The `packages/`, `heads/`, `dist/` layout
|
|
60
52
|
- **[Testing](https://github.com/CategoricalData/hydra/wiki/Testing)** -
|
|
61
|
-
|
|
53
|
+
Hydra-kernel test suite documentation
|
|
62
54
|
- **[Developer Recipes](https://github.com/CategoricalData/hydra/blob/main/docs/recipes/index.md)** -
|
|
63
55
|
Step-by-step guides
|
|
64
56
|
- **[Syncing Hydra-Python](https://github.com/CategoricalData/hydra/blob/main/docs/recipes/syncing-python.md)** -
|
|
@@ -66,15 +58,15 @@ For comprehensive documentation about Hydra's architecture and usage, see:
|
|
|
66
58
|
|
|
67
59
|
## Testing
|
|
68
60
|
|
|
69
|
-
Hydra-Python has two types of tests: the **
|
|
61
|
+
Hydra-Python has two types of tests: the **hydra-kernel test suite** (shared across all Hydra implementations)
|
|
70
62
|
and **Python-specific tests**.
|
|
71
63
|
See the [Testing wiki page](https://github.com/CategoricalData/hydra/wiki/Testing)
|
|
72
64
|
for comprehensive documentation.
|
|
73
65
|
|
|
74
|
-
###
|
|
66
|
+
### Hydra-kernel test suite
|
|
75
67
|
|
|
76
|
-
The
|
|
77
|
-
**Passing all
|
|
68
|
+
The hydra-kernel test suite (`hydra.test.testSuite`) ensures parity across all Hydra implementations.
|
|
69
|
+
**Passing all hydra-kernel test suite cases is the criterion for a true Hydra implementation.**
|
|
78
70
|
|
|
79
71
|
To run all tests (from `heads/python/`):
|
|
80
72
|
|
|
@@ -82,7 +74,7 @@ To run all tests (from `heads/python/`):
|
|
|
82
74
|
cd heads/python && pytest
|
|
83
75
|
```
|
|
84
76
|
|
|
85
|
-
To run only the
|
|
77
|
+
To run only the hydra-kernel test suite:
|
|
86
78
|
|
|
87
79
|
```bash
|
|
88
80
|
cd heads/python && pytest src/test/python/test_suite_runner.py
|
|
@@ -100,7 +92,7 @@ The test suite is generated from Hydra DSL sources and includes:
|
|
|
100
92
|
### Python-specific tests
|
|
101
93
|
|
|
102
94
|
Python-specific tests validate implementation details and Python-specific functionality.
|
|
103
|
-
These are located in `heads/python/src/test/python/` alongside the
|
|
95
|
+
These are located in `heads/python/src/test/python/` alongside the hydra-kernel test suite runner.
|
|
104
96
|
|
|
105
97
|
To run a specific test file:
|
|
106
98
|
|
|
@@ -134,10 +126,10 @@ Hydra's Python code is split across three locations
|
|
|
134
126
|
- **Python kernel overlay** ([`overlay/python/hydra-kernel/src/main/python/`](https://github.com/CategoricalData/hydra/tree/main/overlay/python/hydra-kernel/src/main/python))
|
|
135
127
|
— hand-written Python kernel runtime, overlaid onto `dist/python/hydra-kernel/`
|
|
136
128
|
by `heads/python/bin/copy-kernel-runtime.sh` so the published `hydra-kernel` wheel is self-contained
|
|
137
|
-
- `hydra/lib/` — primitive function implementations
|
|
138
|
-
- `hydra/dsl/` — DSL utilities (FrozenDict, Maybe, ...)
|
|
139
|
-
- `hydra/python/util/` — `ConsList`, `Lazy`, `PersistentMap`, `PersistentSet`
|
|
140
|
-
- `hydra/sources/libraries.py` — primitive registration
|
|
129
|
+
- `hydra/overlay/python/lib/` — primitive function implementations
|
|
130
|
+
- `hydra/overlay/python/dsl/` — DSL utilities (FrozenDict, Maybe, ...)
|
|
131
|
+
- `hydra/overlay/python/util/` — `ConsList`, `Lazy`, `PersistentMap`, `PersistentSet`
|
|
132
|
+
- `hydra/overlay/python/sources/libraries.py` — primitive registration
|
|
141
133
|
- **Python head** ([`heads/python/src/main/python/`](https://github.com/CategoricalData/hydra/tree/main/heads/python/src/main/python))
|
|
142
134
|
— bootstrap layer above the kernel (`bootstrap.py`, `generation.py`, the `hydra.python` coder
|
|
143
135
|
package). `pyproject.toml` lives in `heads/python/`.
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"digestFormatVersion": 1,
|
|
3
3
|
"moduleFormatVersion": 1,
|
|
4
|
-
"generator": "
|
|
4
|
+
"generator": "983e925152c14e7d",
|
|
5
5
|
"generation": {
|
|
6
|
-
"generatorId": "
|
|
6
|
+
"generatorId": "983e925152c14e7d",
|
|
7
7
|
"mode": "published",
|
|
8
|
-
"hydraVersion": "0.17.
|
|
9
|
-
"revision": "
|
|
10
|
-
"timestamp": "2026-07-
|
|
8
|
+
"hydraVersion": "0.17.2",
|
|
9
|
+
"revision": "fa099dc0f8",
|
|
10
|
+
"timestamp": "2026-07-31T15:44:34Z",
|
|
11
11
|
"host": "python"
|
|
12
12
|
},
|
|
13
|
-
"selfHash": "
|
|
14
|
-
"depHash:hydra-kernel": "
|
|
13
|
+
"selfHash": "8f12cad96047b0fe5cef599a843cbf5dd50d077d099b2a8462568a9b9064536b",
|
|
14
|
+
"depHash:hydra-kernel": "331eaf0751864ad00dbe4f2d53a1bf6c95709e006df1c87c98284a5efb306708",
|
|
15
15
|
"inputs": {
|
|
16
|
-
"hydra.python.coder": { "kind": "Other", "hash": "
|
|
16
|
+
"hydra.python.coder": { "kind": "Other", "hash": "784bf72060179ad7c64e71008b68892b98b081a2826fc337768bf0b0e97cfc6f" },
|
|
17
17
|
"hydra.python.environment": { "kind": "Other", "hash": "e14b76188ef4da15c8f011740ed2751e9b55cd0e13f9d9e9d6917cb644526ac9" },
|
|
18
18
|
"hydra.python.language": { "kind": "Other", "hash": "78fb867a1d0fa6654f46f5d9fd72c2c5607d2934b7c7fbd5f5d830786b4ad91e" },
|
|
19
|
-
"hydra.python.names": { "kind": "Other", "hash": "
|
|
19
|
+
"hydra.python.names": { "kind": "Other", "hash": "f0e81d57cda13bc617185cc2d09240091e816ba9fb2e1c9e6091ef888ea34e22" },
|
|
20
20
|
"hydra.python.pyproject": { "kind": "Other", "hash": "249512648b2b008db234ee348a72056d4d625cfeb0a80d8caacbda95002569a2" },
|
|
21
|
-
"hydra.python.serde": { "kind": "Other", "hash": "
|
|
21
|
+
"hydra.python.serde": { "kind": "Other", "hash": "9285fa0296e940da1de51a53465598455c46404851aefc2ce15220fc6ee7efc6" },
|
|
22
22
|
"hydra.python.syntax": { "kind": "Other", "hash": "88a9154b48fd429f06efa0ba8981bdf12af3fed4de5a057b3304fadc623dbc19" },
|
|
23
|
-
"hydra.python.testing": { "kind": "Other", "hash": "
|
|
24
|
-
"hydra.python.utils": { "kind": "Other", "hash": "
|
|
23
|
+
"hydra.python.testing": { "kind": "Other", "hash": "a40b949c594c81f8925ba423a89e46964b2b1475d44a486aa07c792c2c7f807b" },
|
|
24
|
+
"hydra.python.utils": { "kind": "Other", "hash": "d5769b4f1a6952f8786b77a7e9e1699b278eb514879174b5a9dd7b08e4b55686" },
|
|
25
25
|
"jsonContent:hydra/dsl/python/environment.json": { "kind": "Other", "hash": "670d83127f7a308b11a577e3481eb9926d366a1046ab99a5e1578b0bf72159c4" },
|
|
26
26
|
"jsonContent:hydra/dsl/python/names.json": { "kind": "Other", "hash": "244d73ec6a140f89bafcbb87dc8570a09f50151508aa0443708e7070749be876" },
|
|
27
27
|
"jsonContent:hydra/dsl/python/syntax.json": { "kind": "Other", "hash": "a99b94b1f3e542d606da15fd6dafa32d858ce7d71ba02f7b21d8bb4881daa4e3" },
|
|
28
28
|
"jsonContent:hydra/dsl/python/utils.json": { "kind": "Other", "hash": "5464cb8e1db43a03b98327746b668050f4159a90f13ce5334c32e6d7dbbceb4c" },
|
|
29
|
-
"jsonContent:hydra/python/coder.json": { "kind": "Other", "hash": "
|
|
29
|
+
"jsonContent:hydra/python/coder.json": { "kind": "Other", "hash": "7bd00830dda91a23bddb7d1fd36ea48e79821a81778b809a50924ac959619b61" },
|
|
30
30
|
"jsonContent:hydra/python/environment.json": { "kind": "Other", "hash": "b5bc63f7d18f47262c90738cb793098f88a97376fd52088b3c8661c1d9ea5cbd" },
|
|
31
31
|
"jsonContent:hydra/python/language.json": { "kind": "Other", "hash": "221e68d68030945db181fdd079be4ff619cb4cd1ad5d4b72b4e70f2aa1bd5230" },
|
|
32
|
-
"jsonContent:hydra/python/names.json": { "kind": "Other", "hash": "
|
|
32
|
+
"jsonContent:hydra/python/names.json": { "kind": "Other", "hash": "51a59a9f21446bb6cfb128e4830c74e33a42ddaffbe67afddfa55d9fee610fb9" },
|
|
33
33
|
"jsonContent:hydra/python/pyproject.json": { "kind": "Other", "hash": "c94de46f1615e6e82d2f706d01ef04293373f6241a9a42882bb394d51b4f7f53" },
|
|
34
|
-
"jsonContent:hydra/python/serde.json": { "kind": "Other", "hash": "
|
|
34
|
+
"jsonContent:hydra/python/serde.json": { "kind": "Other", "hash": "648d34f63d2336972d5e0a59d4871332a07bd35c88eb38c28236e16a7fd48601" },
|
|
35
35
|
"jsonContent:hydra/python/syntax.json": { "kind": "Other", "hash": "8dc3a26ac927fa338b273c9deee6317906977a2deec4c2df1e44ff0bbe0a64cd" },
|
|
36
|
-
"jsonContent:hydra/python/testing.json": { "kind": "Other", "hash": "
|
|
37
|
-
"jsonContent:hydra/python/utils.json": { "kind": "Other", "hash": "
|
|
36
|
+
"jsonContent:hydra/python/testing.json": { "kind": "Other", "hash": "9c75b534004194396935b1dd3331bae4d8d5cbb31c3959fa3794dda00960c09a" },
|
|
37
|
+
"jsonContent:hydra/python/utils.json": { "kind": "Other", "hash": "fea597ac6c71916255914f8196c377b780d32b475b5b81cd1c0a087b8abe87c3" },
|
|
38
38
|
"jsonContent:manifest.json": { "kind": "Other", "hash": "3f94b521766d042381d7bee84596308ea4e35c7e8fb45f8fd8338a8dbe27a0ac" }
|
|
39
39
|
},
|
|
40
40
|
"outputs": {
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"hydra/dsl/python/names.py": { "kind": "TargetFile", "hash": "3733bed7b32e56239c4c2dd5a748e66ee0f5b9eff629687648a5ebe232508a93" },
|
|
43
43
|
"hydra/dsl/python/syntax.py": { "kind": "TargetFile", "hash": "5fe1c0c739cdac68d1b90d768153e23ebe7c805bafb96ac698a95425e2d7d7b5" },
|
|
44
44
|
"hydra/dsl/python/utils.py": { "kind": "TargetFile", "hash": "fbf8522b1d5c64eb570027d579b512caf7ae3853f010b4e4666746df6d262812" },
|
|
45
|
-
"hydra/python/coder.py": { "kind": "TargetFile", "hash": "
|
|
45
|
+
"hydra/python/coder.py": { "kind": "TargetFile", "hash": "8a2d415e5e026b13d6c7fd620dcce839443f028cc34720a79e6a2de482f06238" },
|
|
46
46
|
"hydra/python/environment.py": { "kind": "TargetFile", "hash": "240979735f3a2d479403834c1a4d7a16f060ad447eb4f3b05fbb2db591d7ad0b" },
|
|
47
47
|
"hydra/python/language.py": { "kind": "TargetFile", "hash": "7ea0c3a6015ec1de92aebeed0963c1af9f3b70c8d57815e477c528c795383604" },
|
|
48
|
-
"hydra/python/names.py": { "kind": "TargetFile", "hash": "
|
|
48
|
+
"hydra/python/names.py": { "kind": "TargetFile", "hash": "09490cd34e878fa3c9ad7940171b86a60843fe7591f78d7bb57eb3c52c4edc2e" },
|
|
49
49
|
"hydra/python/pyproject.py": { "kind": "TargetFile", "hash": "1f9001d8d2273d4783105e099b874c273ce520b58456f9b447cb8d5e9a6a37d7" },
|
|
50
|
-
"hydra/python/serde.py": { "kind": "TargetFile", "hash": "
|
|
50
|
+
"hydra/python/serde.py": { "kind": "TargetFile", "hash": "ad1714baddb710cd3f345c339a9e6a55862197660cd065ac84d3736716792cbf" },
|
|
51
51
|
"hydra/python/syntax.py": { "kind": "TargetFile", "hash": "24a72af882b47d80cc930f16f51a3e9c1a71c9d8da47a921829f40e847459fca" },
|
|
52
|
-
"hydra/python/testing.py": { "kind": "TargetFile", "hash": "
|
|
53
|
-
"hydra/python/utils.py": { "kind": "TargetFile", "hash": "
|
|
52
|
+
"hydra/python/testing.py": { "kind": "TargetFile", "hash": "2b9137ccd1449a8c636c59df9dc5d83662ed1e9547802ba6b8c2c5db5ee29710" },
|
|
53
|
+
"hydra/python/utils.py": { "kind": "TargetFile", "hash": "05504b0be6dff96d72997295abd89a5510bbc8580b48f85bd25575b313e19645" }
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
[project]
|
|
15
15
|
name = "hydra-python"
|
|
16
|
-
version = "0.17.
|
|
16
|
+
version = "0.17.3"
|
|
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.3",
|
|
26
26
|
]
|
|
27
27
|
|
|
28
28
|
[project.urls]
|
|
@@ -30,12 +30,14 @@ import hydra.overlay.python.lib.logic
|
|
|
30
30
|
import hydra.overlay.python.lib.maps
|
|
31
31
|
import hydra.overlay.python.lib.math
|
|
32
32
|
import hydra.overlay.python.lib.optionals
|
|
33
|
+
import hydra.overlay.python.lib.ordering
|
|
33
34
|
import hydra.overlay.python.lib.pairs
|
|
34
35
|
import hydra.overlay.python.lib.sets
|
|
35
36
|
import hydra.overlay.python.lib.strings
|
|
36
37
|
import hydra.names
|
|
37
38
|
import hydra.packaging
|
|
38
39
|
import hydra.predicates
|
|
40
|
+
import hydra.print.core
|
|
39
41
|
import hydra.python.environment
|
|
40
42
|
import hydra.python.names
|
|
41
43
|
import hydra.python.serde
|
|
@@ -46,7 +48,6 @@ import hydra.resolution
|
|
|
46
48
|
import hydra.rewriting
|
|
47
49
|
import hydra.scoping
|
|
48
50
|
import hydra.serialization
|
|
49
|
-
import hydra.show.core
|
|
50
51
|
import hydra.strip
|
|
51
52
|
import hydra.typing
|
|
52
53
|
import hydra.util
|
|
@@ -97,7 +98,7 @@ def builder_setter_name(env: hydra.python.environment.PythonEnvironment, fname:
|
|
|
97
98
|
base = Lazy((lambda : hydra.python.names.encode_field_name(env, fname).value))
|
|
98
99
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.or_(hydra.overlay.python.lib.equality.equal(base(), "build"),
|
|
99
100
|
hydra.overlay.python.lib.logic.or_(hydra.overlay.python.lib.equality.equal(base(), "builder"), hydra.overlay.python.lib.equality.equal(base(), "self"))),
|
|
100
|
-
(lambda : hydra.overlay.python.lib.strings.
|
|
101
|
+
(lambda : hydra.overlay.python.lib.strings.concat2(base(), "_")),
|
|
101
102
|
(lambda : base()))
|
|
102
103
|
|
|
103
104
|
def deconflict_variant_name(is_qualified: bool,
|
|
@@ -107,12 +108,12 @@ fname: hydra.core.Name,
|
|
|
107
108
|
g: hydra.graph.Graph) -> hydra.python.syntax.Name:
|
|
108
109
|
r"""Deconflict a variant name to avoid collisions with type names."""
|
|
109
110
|
|
|
110
|
-
candidate_hydra_name = Lazy((lambda : hydra.core.Name(hydra.overlay.python.lib.strings.
|
|
111
|
+
candidate_hydra_name = Lazy((lambda : hydra.core.Name(hydra.overlay.python.lib.strings.concat2(union_name.value, hydra.formatting.capitalize(fname.value)))))
|
|
111
112
|
term_collision = Lazy((lambda : hydra.overlay.python.lib.maps.member(candidate_hydra_name(), g.bound_terms)))
|
|
112
113
|
type_collision = Lazy((lambda : hydra.overlay.python.lib.maps.member(candidate_hydra_name(), g.schema_types)))
|
|
113
114
|
collision = Lazy((lambda : hydra.overlay.python.lib.logic.or_(term_collision(), type_collision())))
|
|
114
115
|
return hydra.overlay.python.lib.logic.if_else(collision(),
|
|
115
|
-
(lambda : hydra.python.syntax.Name(hydra.overlay.python.lib.strings.
|
|
116
|
+
(lambda : hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2(hydra.python.names.variant_name(is_qualified, env, union_name, fname).value, "_"))),
|
|
116
117
|
(lambda : hydra.python.names.variant_name(is_qualified, env, union_name, fname)))
|
|
117
118
|
|
|
118
119
|
def eliminate_unit_var(v: hydra.core.Name, term0: hydra.core.Term) -> hydra.core.Term:
|
|
@@ -195,7 +196,7 @@ def is_variant_unit_type(row_type: Sequence[hydra.core.FieldType], field_name: h
|
|
|
195
196
|
r"""Check if a variant field has unit type."""
|
|
196
197
|
|
|
197
198
|
mfield = Lazy((lambda : hydra.overlay.python.lib.lists.find((lambda ft: hydra.overlay.python.lib.equality.equal(ft.name, field_name)), row_type)))
|
|
198
|
-
return hydra.overlay.python.lib.optionals.
|
|
199
|
+
return hydra.overlay.python.lib.optionals.with_default((lambda : False),
|
|
199
200
|
hydra.overlay.python.lib.optionals.map((lambda ft: hydra.predicates.is_unit_type(hydra.strip.deannotate_type(ft.type))), mfield()))
|
|
200
201
|
|
|
201
202
|
def class_variant_pattern_unit(py_variant_name: hydra.python.syntax.Name) -> hydra.python.syntax.ClosedPattern:
|
|
@@ -331,7 +332,7 @@ def deduplicate_case_variables(cases_: Sequence[hydra.core.CaseAlternative]) ->
|
|
|
331
332
|
(lambda : (hydra.overlay.python.lib.maps.insert(v, 1, count_by_name()), hydra.overlay.python.lib.lists.cons(field, done()))),
|
|
332
333
|
(lambda count: (
|
|
333
334
|
count2 := Lazy((lambda : hydra.overlay.python.lib.math.add(count, 1))),
|
|
334
|
-
v2 := Lazy((lambda : hydra.core.Name(hydra.overlay.python.lib.strings.
|
|
335
|
+
v2 := Lazy((lambda : hydra.core.Name(hydra.overlay.python.lib.strings.concat2(v.value, hydra.overlay.python.lib.literals.show_int32(count2.get()))))),
|
|
335
336
|
new_body := Lazy((lambda : hydra.reduction.alpha_convert(v, v2.get(), body))),
|
|
336
337
|
new_lam := Lazy((lambda : hydra.core.Lambda(v2.get(), mdom, new_body.get()))),
|
|
337
338
|
new_term := Lazy((lambda : cast(hydra.core.Term, hydra.core.TermLambda(new_lam.get())))),
|
|
@@ -795,7 +796,7 @@ def encode_function_type(env: hydra.python.environment.PythonEnvironment, ft: hy
|
|
|
795
796
|
def encode_type(env: hydra.python.environment.PythonEnvironment, typ: hydra.core.Type) -> Either[T0, hydra.python.syntax.Expression]:
|
|
796
797
|
r"""Encode a Hydra type to a Python type expression."""
|
|
797
798
|
|
|
798
|
-
dflt = Lazy((lambda : Right(hydra.python.utils.double_quoted_string(hydra.overlay.python.lib.strings.
|
|
799
|
+
dflt = Lazy((lambda : Right(hydra.python.utils.double_quoted_string(hydra.overlay.python.lib.strings.concat2("type = ", hydra.print.core.type(hydra.strip.deannotate_type(typ)))))))
|
|
799
800
|
match hydra.strip.deannotate_type(typ):
|
|
800
801
|
case hydra.core.TypeApplication(value=at):
|
|
801
802
|
return encode_application_type(env, at)
|
|
@@ -876,7 +877,7 @@ def lazy_dot_get(expr: hydra.python.syntax.Expression) -> hydra.python.syntax.Ex
|
|
|
876
877
|
def make_simple_lambda(arity: int, lhs: hydra.python.syntax.Expression) -> hydra.python.syntax.Expression:
|
|
877
878
|
r"""Wrap a bare reference to a polymorphic function in an uncurried lambda."""
|
|
878
879
|
|
|
879
|
-
args = Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda i: hydra.python.syntax.Name(hydra.overlay.python.lib.strings.
|
|
880
|
+
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)))),
|
|
880
881
|
hydra.overlay.python.lib.math.range_(1, arity))))
|
|
881
882
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(arity, 0),
|
|
882
883
|
(lambda : lhs),
|
|
@@ -936,7 +937,7 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
936
937
|
(lambda : (
|
|
937
938
|
num_remaining := Lazy((lambda : hydra.overlay.python.lib.math.sub(prim_arity.get(), hydra.overlay.python.lib.lists.length(args)))),
|
|
938
939
|
(
|
|
939
|
-
remaining_params := Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda i: hydra.python.syntax.Name(hydra.overlay.python.lib.strings.
|
|
940
|
+
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)))),
|
|
940
941
|
hydra.overlay.python.lib.math.range_(1, num_remaining.get())))),
|
|
941
942
|
(
|
|
942
943
|
remaining_exprs := Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda n: cast(hydra.python.syntax.Expression,
|
|
@@ -969,7 +970,7 @@ args: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, hy
|
|
|
969
970
|
(lambda : hydra.overlay.python.lib.optionals.cases(hydra.lexical.lookup_binding(g(), name),
|
|
970
971
|
(lambda : hydra.overlay.python.lib.optionals.cases(hydra.overlay.python.lib.maps.lookup(name, tc_metadata),
|
|
971
972
|
(lambda : Left(cast(hydra.errors.Error,
|
|
972
|
-
hydra.errors.ErrorOther(hydra.errors.OtherError(hydra.overlay.python.lib.strings.
|
|
973
|
+
hydra.errors.ErrorOther(hydra.errors.OtherError(hydra.overlay.python.lib.strings.concat2("Unknown variable: ", name.value)))))),
|
|
973
974
|
(lambda _: Right(as_function_call())))),
|
|
974
975
|
(lambda el: (
|
|
975
976
|
el_trivial1 := Lazy((lambda : hydra.predicates.is_trivial_term(el.term))),
|
|
@@ -1125,7 +1126,7 @@ def term_arity_with_primitives(graph: hydra.graph.Graph, term: hydra.core.Term)
|
|
|
1125
1126
|
|
|
1126
1127
|
match hydra.strip.deannotate_and_detype_term(term):
|
|
1127
1128
|
case hydra.core.TermApplication(value=app):
|
|
1128
|
-
return hydra.overlay.python.lib.
|
|
1129
|
+
return hydra.overlay.python.lib.ordering.max(0, hydra.overlay.python.lib.math.sub(term_arity_with_primitives(graph, app.function), 1))
|
|
1129
1130
|
|
|
1130
1131
|
case hydra.core.TermLambda(value=lam):
|
|
1131
1132
|
return hydra.overlay.python.lib.math.add(1, term_arity_with_primitives(graph, lam.body))
|
|
@@ -1156,7 +1157,7 @@ def encode_application(cx: hydra.typing.InferenceContext, env: hydra.python.envi
|
|
|
1156
1157
|
fun = Lazy((lambda : hydra.overlay.python.lib.pairs.first(gathered())))
|
|
1157
1158
|
args = Lazy((lambda : hydra.overlay.python.lib.pairs.second(gathered())))
|
|
1158
1159
|
known_arity = Lazy((lambda : term_arity_with_primitives(g(), fun())))
|
|
1159
|
-
arity = Lazy((lambda : hydra.overlay.python.lib.
|
|
1160
|
+
arity = Lazy((lambda : hydra.overlay.python.lib.ordering.max(known_arity(), hydra.overlay.python.lib.lists.length(args()))))
|
|
1160
1161
|
return hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.eithers.map_list((lambda t: encode_term_inline(cx, env, False, t)), args()),
|
|
1161
1162
|
(lambda pargs: (
|
|
1162
1163
|
hargs := Lazy((lambda : hydra.overlay.python.lib.lists.take(arity(), pargs))),
|
|
@@ -1177,7 +1178,7 @@ hargs: Sequence[hydra.python.syntax.Expression],
|
|
|
1177
1178
|
rargs: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, tuple[hydra.python.syntax.Expression, Sequence[hydra.python.syntax.Expression]]]:
|
|
1178
1179
|
r"""Inner helper for encodeApplication."""
|
|
1179
1180
|
|
|
1180
|
-
first_arg = Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
1181
|
+
first_arg = Lazy((lambda : hydra.overlay.python.lib.optionals.with_default((lambda : hydra.python.utils.py_name_to_py_expression(hydra.python.syntax.Name(""))), hydra.overlay.python.lib.lists.head(hargs))))
|
|
1181
1182
|
rest_args = Lazy((lambda : hydra.overlay.python.lib.lists.drop(1, hargs)))
|
|
1182
1183
|
def with_rest(e: hydra.python.syntax.Expression) -> hydra.python.syntax.Expression:
|
|
1183
1184
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.null(rest_args()),
|
|
@@ -1218,7 +1219,7 @@ rargs: Sequence[hydra.python.syntax.Expression]) -> Either[hydra.errors.Error, t
|
|
|
1218
1219
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_variable(cx, env, name, hargs), (lambda expr: Right((expr, rargs))))),
|
|
1219
1220
|
(lambda ts: (
|
|
1220
1221
|
el_arity := Lazy((lambda : hydra.arity.type_scheme_arity(ts))),
|
|
1221
|
-
consume_count := Lazy((lambda : hydra.overlay.python.lib.
|
|
1222
|
+
consume_count := Lazy((lambda : hydra.overlay.python.lib.ordering.min(el_arity.get(), hydra.overlay.python.lib.lists.length(all_args())))),
|
|
1222
1223
|
consumed_args := Lazy((lambda : hydra.overlay.python.lib.lists.take(consume_count.get(), all_args()))),
|
|
1223
1224
|
remaining_args := Lazy((lambda : hydra.overlay.python.lib.lists.drop(consume_count.get(), all_args()))),
|
|
1224
1225
|
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.null(consumed_args.get()),
|
|
@@ -1557,7 +1558,7 @@ tname: hydra.core.Name) -> Either[T1, Sequence[hydra.python.syntax.CaseBlock]]:
|
|
|
1557
1558
|
return hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.optionals.cases(mdflt,
|
|
1558
1559
|
(lambda : Right(hydra.overlay.python.lib.logic.if_else(is_full,
|
|
1559
1560
|
(lambda : hydra.python.utils.raise_assertion_error("Unreachable: all variants handled")),
|
|
1560
|
-
(lambda : hydra.python.utils.raise_type_error(hydra.overlay.python.lib.strings.
|
|
1561
|
+
(lambda : hydra.python.utils.raise_type_error(hydra.overlay.python.lib.strings.concat2("Unsupported ", hydra.names.local_name_of(tname))))))),
|
|
1561
1562
|
(lambda d: hydra.overlay.python.lib.eithers.bind(term_to_expr(d), (lambda pyexpr: Right(hydra.python.utils.return_single(pyexpr)))))),
|
|
1562
1563
|
(lambda stmt: (
|
|
1563
1564
|
patterns := Lazy((lambda : hydra.python.utils.py_closed_pattern_to_py_patterns(cast(hydra.python.syntax.ClosedPattern, hydra.python.syntax.ClosedPatternWildcard())))),
|
|
@@ -1576,7 +1577,7 @@ def is_cases_full(row_type: Sequence[T0], cases_: Sequence[T1]) -> bool:
|
|
|
1576
1577
|
|
|
1577
1578
|
num_cases = Lazy((lambda : hydra.overlay.python.lib.lists.length(cases_)))
|
|
1578
1579
|
num_fields = Lazy((lambda : hydra.overlay.python.lib.lists.length(row_type)))
|
|
1579
|
-
return hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.
|
|
1580
|
+
return hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.ordering.lt(num_cases(), num_fields()))
|
|
1580
1581
|
|
|
1581
1582
|
def encode_term_multiline_t_c_o(cx: hydra.typing.InferenceContext,
|
|
1582
1583
|
env: hydra.python.environment.PythonEnvironment,
|
|
@@ -1610,7 +1611,7 @@ term: hydra.core.Term) -> Either[hydra.errors.Error, Sequence[hydra.python.synta
|
|
|
1610
1611
|
body2 := Lazy((lambda : hydra.overlay.python.lib.pairs.second(gathered2.get()))),
|
|
1611
1612
|
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(hydra.overlay.python.lib.lists.length(args2.get()), 1),
|
|
1612
1613
|
(lambda : (
|
|
1613
|
-
arg := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
1614
|
+
arg := Lazy((lambda : hydra.overlay.python.lib.optionals.with_default((lambda : cast(hydra.core.Term, hydra.core.TermUnit())), hydra.overlay.python.lib.lists.head(args2.get())))),
|
|
1614
1615
|
(
|
|
1615
1616
|
_hoist_arg_body_1 := Lazy((lambda : (lambda v1: (lambda cs: (
|
|
1616
1617
|
tname := Lazy((lambda : cs.type_name)),
|
|
@@ -1715,7 +1716,7 @@ def is_case_statement_application(term: hydra.core.Term) -> Optional[tuple[hydra
|
|
|
1715
1716
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.not_(hydra.overlay.python.lib.equality.equal(hydra.overlay.python.lib.lists.length(args()), 1)),
|
|
1716
1717
|
(lambda : None_()),
|
|
1717
1718
|
(lambda : (
|
|
1718
|
-
arg := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
1719
|
+
arg := Lazy((lambda : hydra.overlay.python.lib.optionals.with_default((lambda : cast(hydra.core.Term, hydra.core.TermUnit())), hydra.overlay.python.lib.lists.head(args())))),
|
|
1719
1720
|
(
|
|
1720
1721
|
_hoist_arg_body_1 := Lazy((lambda : (lambda v1: (lambda cs: Given((cs.type_name, (cs.default, (cs.cases, arg.get())))))(v1.value) if isinstance(v1, hydra.core.TermCases) else None_()))),
|
|
1721
1722
|
_hoist_arg_body_1.get()(hydra.strip.deannotate_and_detype_term(body())))[1])[1]))
|
|
@@ -1741,7 +1742,7 @@ def encode_binding_as(cx: hydra.typing.InferenceContext, env: hydra.python.envir
|
|
|
1741
1742
|
mcs := Lazy((lambda : extract_case_elimination(term1))),
|
|
1742
1743
|
hydra.overlay.python.lib.optionals.cases(mcs.get(),
|
|
1743
1744
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_term_multiline(cx, env, term1),
|
|
1744
|
-
(lambda stmts: hydra.overlay.python.lib.optionals.cases(hydra.overlay.python.lib.lists.
|
|
1745
|
+
(lambda stmts: hydra.overlay.python.lib.optionals.cases(hydra.overlay.python.lib.lists.head(stmts),
|
|
1745
1746
|
(lambda : Left(cast(hydra.errors.Error, hydra.errors.ErrorOther(hydra.errors.OtherError("encodeTermMultiline returned no statements"))))),
|
|
1746
1747
|
(lambda x: Right(x)))))),
|
|
1747
1748
|
(lambda cs: (
|
|
@@ -1777,7 +1778,7 @@ def encode_binding_as(cx: hydra.typing.InferenceContext, env: hydra.python.envir
|
|
|
1777
1778
|
mcs := Lazy((lambda : extract_case_elimination(term1))),
|
|
1778
1779
|
hydra.overlay.python.lib.optionals.cases(mcs.get(),
|
|
1779
1780
|
(lambda : hydra.overlay.python.lib.eithers.bind(encode_term_multiline(cx, env, term1),
|
|
1780
|
-
(lambda stmts: hydra.overlay.python.lib.optionals.cases(hydra.overlay.python.lib.lists.
|
|
1781
|
+
(lambda stmts: hydra.overlay.python.lib.optionals.cases(hydra.overlay.python.lib.lists.head(stmts),
|
|
1781
1782
|
(lambda : Left(cast(hydra.errors.Error, hydra.errors.ErrorOther(hydra.errors.OtherError("encodeTermMultiline returned no statements"))))),
|
|
1782
1783
|
(lambda x: Right(x)))))),
|
|
1783
1784
|
(lambda cs: (
|
|
@@ -1822,8 +1823,8 @@ def encode_binding_as(cx: hydra.typing.InferenceContext, env: hydra.python.envir
|
|
|
1822
1823
|
(lambda rt: (
|
|
1823
1824
|
is_enum := Lazy((lambda : hydra.predicates.is_enum_row_type(rt))),
|
|
1824
1825
|
is_full := Lazy((lambda : is_cases_full(rt, cases_.get()))),
|
|
1825
|
-
captured_var_names := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
1826
|
-
match_lambda_param := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
1826
|
+
captured_var_names := Lazy((lambda : hydra.overlay.python.lib.optionals.with_default((lambda : ConsList.of()), hydra.overlay.python.lib.lists.init(lambda_params.get())))),
|
|
1827
|
+
match_lambda_param := Lazy((lambda : hydra.overlay.python.lib.optionals.with_default((lambda : hydra.core.Name("")), hydra.overlay.python.lib.lists.last(lambda_params.get())))),
|
|
1827
1828
|
captured_params := Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda n: hydra.python.syntax.ParamNoDefault(hydra.python.syntax.Param(hydra.python.names.encode_name(False, hydra.util.CaseConvention.LOWER_SNAKE, env, n), None_()),
|
|
1828
1829
|
None_())),
|
|
1829
1830
|
captured_var_names.get()))),
|
|
@@ -1914,7 +1915,7 @@ def encode_term_multiline(cx: hydra.typing.InferenceContext, env: hydra.python.e
|
|
|
1914
1915
|
body = Lazy((lambda : hydra.overlay.python.lib.pairs.second(gathered())))
|
|
1915
1916
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(hydra.overlay.python.lib.lists.length(args()), 1),
|
|
1916
1917
|
(lambda : (
|
|
1917
|
-
arg := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
1918
|
+
arg := Lazy((lambda : hydra.overlay.python.lib.optionals.with_default((lambda : cast(hydra.core.Term, hydra.core.TermUnit())), hydra.overlay.python.lib.lists.head(args())))),
|
|
1918
1919
|
(
|
|
1919
1920
|
_hoist_arg_body_1 := Lazy((lambda : (lambda v1: (lambda cs: (
|
|
1920
1921
|
tname := Lazy((lambda : cs.type_name)),
|
|
@@ -2048,7 +2049,7 @@ def record_builder_setter(env: hydra.python.environment.PythonEnvironment, field
|
|
|
2048
2049
|
fname = field_type.name
|
|
2049
2050
|
setter_name = Lazy((lambda : builder_setter_name(env, fname)))
|
|
2050
2051
|
param_name = hydra.python.syntax.Name(setter_name())
|
|
2051
|
-
storage_name = Lazy((lambda : hydra.overlay.python.lib.strings.
|
|
2052
|
+
storage_name = Lazy((lambda : hydra.overlay.python.lib.strings.concat2("_", hydra.python.names.encode_field_name(env, field_type.name).value)))
|
|
2052
2053
|
kwarg = Lazy((lambda : cast(hydra.python.syntax.KwargOrStarred,
|
|
2053
2054
|
hydra.python.syntax.KwargOrStarredKwarg(hydra.python.syntax.Kwarg(hydra.python.syntax.Name(storage_name()), hydra.python.utils.py_name_to_py_expression(param_name))))))
|
|
2054
2055
|
return cast(hydra.python.syntax.Statement,
|
|
@@ -2080,7 +2081,7 @@ record_args: Optional[hydra.python.syntax.Args]) -> Either[T0, Sequence[hydra.py
|
|
|
2080
2081
|
|
|
2081
2082
|
return hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.eithers.map_list((lambda ft: hydra.overlay.python.lib.eithers.map((lambda py_type: hydra.python.utils.py_assignment_to_py_statement(cast(hydra.python.syntax.Assignment,
|
|
2082
2083
|
hydra.python.syntax.AssignmentTyped(hydra.python.syntax.TypedAssignment(cast(hydra.python.syntax.SingleTarget,
|
|
2083
|
-
hydra.python.syntax.SingleTargetName(hydra.python.syntax.Name(hydra.overlay.python.lib.strings.
|
|
2084
|
+
hydra.python.syntax.SingleTargetName(hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2("_", hydra.python.names.encode_field_name(env, ft.name).value)))),
|
|
2084
2085
|
py_type,
|
|
2085
2086
|
Given(cast(hydra.python.syntax.AnnotatedRhs,
|
|
2086
2087
|
hydra.python.syntax.AnnotatedRhsStar(ConsList.of(cast(hydra.python.syntax.StarExpression,
|
|
@@ -2093,7 +2094,7 @@ record_args: Optional[hydra.python.syntax.Args]) -> Either[T0, Sequence[hydra.py
|
|
|
2093
2094
|
build_kwargs := Lazy((lambda : hydra.overlay.python.lib.lists.map((lambda ft: cast(hydra.python.syntax.KwargOrStarred,
|
|
2094
2095
|
hydra.python.syntax.KwargOrStarredKwarg(hydra.python.syntax.Kwarg(hydra.python.syntax.Name(hydra.python.names.encode_field_name(env, ft.name).value),
|
|
2095
2096
|
hydra.python.utils.project_from_expression(hydra.python.utils.py_name_to_py_expression(hydra.python.syntax.Name("self")),
|
|
2096
|
-
hydra.python.syntax.Name(hydra.overlay.python.lib.strings.
|
|
2097
|
+
hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2("_", hydra.python.names.encode_field_name(env, ft.name).value))))))),
|
|
2097
2098
|
row_type))),
|
|
2098
2099
|
ctor_call := Lazy((lambda : hydra.python.utils.py_primary_to_py_expression(hydra.python.utils.primary_with_rhs(hydra.python.utils.py_name_to_py_primary(py_name.get()),
|
|
2099
2100
|
cast(hydra.python.syntax.PrimaryRhs,
|
|
@@ -2115,7 +2116,7 @@ record_args: Optional[hydra.python.syntax.Args]) -> Either[T0, Sequence[hydra.py
|
|
|
2115
2116
|
ConsList.of(hydra.overlay.python.lib.lists.concat(ConsList.of(builder_fields, setters.get(), ConsList.of(build_method.get()))))))),
|
|
2116
2117
|
builder_decs := Lazy((lambda : Given(hydra.python.syntax.Decorators(ConsList.of(dataclass_decorator()))))),
|
|
2117
2118
|
builder_class := Lazy((lambda : hydra.python.utils.py_class_definition_to_py_statement(hydra.python.syntax.ClassDefinition(builder_decs.get(), hydra.python.syntax.Name("Builder"), ConsList.of(), record_args, builder_body.get())))),
|
|
2118
|
-
qualified_builder_name := Lazy((lambda : hydra.python.syntax.Name(hydra.overlay.python.lib.strings.
|
|
2119
|
+
qualified_builder_name := Lazy((lambda : hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2(py_name.get().value, ".Builder")))),
|
|
2119
2120
|
builder_call := Lazy((lambda : hydra.python.utils.function_call(hydra.python.utils.py_name_to_py_primary(qualified_builder_name.get()), ConsList.of()))),
|
|
2120
2121
|
factory_method := Lazy((lambda : cast(hydra.python.syntax.Statement,
|
|
2121
2122
|
hydra.python.syntax.StatementCompound(cast(hydra.python.syntax.CompoundStatement,
|
|
@@ -2136,7 +2137,7 @@ def record_with_method(env: hydra.python.environment.PythonEnvironment, field_ty
|
|
|
2136
2137
|
|
|
2137
2138
|
fname = field_type.name
|
|
2138
2139
|
snake = Lazy((lambda : hydra.python.names.encode_field_name(env, fname).value))
|
|
2139
|
-
method_name = Lazy((lambda : hydra.overlay.python.lib.strings.
|
|
2140
|
+
method_name = Lazy((lambda : hydra.overlay.python.lib.strings.concat2("with_", snake())))
|
|
2140
2141
|
kwarg_key = hydra.python.syntax.Name(snake())
|
|
2141
2142
|
param_snake = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(snake(), "self"), (lambda : "_self"), (lambda : snake()))))
|
|
2142
2143
|
param_name = hydra.python.syntax.Name(param_snake())
|
|
@@ -2248,7 +2249,7 @@ def find_type_params(env: hydra.python.environment.PythonEnvironment, typ: hydra
|
|
|
2248
2249
|
def variant_args(ptype: hydra.python.syntax.Expression, tparams: Sequence[hydra.core.Name]) -> hydra.python.syntax.Args:
|
|
2249
2250
|
r"""Create args for variant (Node[type], Generic[tparams])."""
|
|
2250
2251
|
|
|
2251
|
-
return hydra.python.utils.py_expressions_to_py_args(hydra.overlay.python.lib.optionals.
|
|
2252
|
+
return hydra.python.utils.py_expressions_to_py_args(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(hydra.python.utils.py_primary_to_py_expression(hydra.python.utils.primary_with_expression_slices(cast(hydra.python.syntax.Primary,
|
|
2252
2253
|
hydra.python.syntax.PrimarySimple(cast(hydra.python.syntax.Atom, hydra.python.syntax.AtomName(hydra.python.syntax.Name("Node"))))),
|
|
2253
2254
|
ConsList.of(ptype)))),
|
|
2254
2255
|
generic_arg(tparams))))
|
|
@@ -3180,9 +3181,9 @@ def module_standard_imports(meta: hydra.python.environment.PythonModuleMetadata)
|
|
|
3180
3181
|
cond_import_symbol("TypeAlias", meta.uses_type_alias),
|
|
3181
3182
|
cond_import_symbol("TypeVar", meta.uses_type_var),
|
|
3182
3183
|
cond_import_symbol("cast", meta.uses_cast))))))
|
|
3183
|
-
simplified = Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
3184
|
+
simplified = Lazy((lambda : hydra.overlay.python.lib.optionals.givens(hydra.overlay.python.lib.lists.map((lambda p: (
|
|
3184
3185
|
mod_name := Lazy((lambda : hydra.overlay.python.lib.pairs.first(p))),
|
|
3185
|
-
symbols := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
3186
|
+
symbols := Lazy((lambda : hydra.overlay.python.lib.optionals.givens(hydra.overlay.python.lib.pairs.second(p)))),
|
|
3186
3187
|
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.null(symbols.get()), (lambda : None_()), (lambda : Given((mod_name.get(), symbols.get())))))[2]),
|
|
3187
3188
|
pairs()))))
|
|
3188
3189
|
return hydra.overlay.python.lib.lists.map((lambda p: standard_import_statement(hydra.overlay.python.lib.pairs.first(p), hydra.overlay.python.lib.pairs.second(p))), simplified())
|
|
@@ -3245,7 +3246,7 @@ body: Callable[[hydra.python.environment.PythonEnvironment], T0]) -> T0:
|
|
|
3245
3246
|
|
|
3246
3247
|
bindings = Lazy((lambda : (
|
|
3247
3248
|
_hoist_bindings_1 := Lazy((lambda : (lambda v1: (lambda td: Given(hydra.core.Binding(td.name, td.body, hydra.overlay.python.lib.optionals.map((lambda sig: hydra.scoping.term_signature_to_type_scheme(sig)), td.signature))))(v1.value) if isinstance(v1, hydra.packaging.DefinitionTerm) else (lambda _: None_())(v1.value) if isinstance(v1, hydra.packaging.DefinitionType) else None_()))),
|
|
3248
|
-
hydra.overlay.python.lib.optionals.
|
|
3249
|
+
hydra.overlay.python.lib.optionals.givens(hydra.overlay.python.lib.lists.map((lambda def_: _hoist_bindings_1.get()(def_)), defs)))[1]))
|
|
3249
3250
|
dummy_let = Lazy((lambda : hydra.core.Let(bindings(), cast(hydra.core.Term, hydra.core.TermLiteral(cast(hydra.core.Literal, hydra.core.LiteralString("dummy")))))))
|
|
3250
3251
|
return with_let(env, dummy_let(), body)
|
|
3251
3252
|
|
|
@@ -33,7 +33,7 @@ def encode_constant_for_field_name(env: T0, tname: T1, fname: hydra.core.Name) -
|
|
|
33
33
|
|
|
34
34
|
return hydra.python.syntax.Name(hydra.formatting.convert_case(hydra.util.CaseConvention.CAMEL,
|
|
35
35
|
hydra.util.CaseConvention.UPPER_SNAKE,
|
|
36
|
-
hydra.overlay.python.lib.strings.
|
|
36
|
+
hydra.overlay.python.lib.strings.join("_", hydra.overlay.python.lib.strings.split_on("-", fname.value))))
|
|
37
37
|
|
|
38
38
|
def encode_constant_for_type_name(env: T0, tname: T1) -> hydra.python.syntax.Name:
|
|
39
39
|
r"""Generate a constant name for a type definition."""
|
|
@@ -49,7 +49,7 @@ def overlay_python_module_aliases() -> Mapping[hydra.packaging.ModuleName, str]:
|
|
|
49
49
|
def encode_namespace_string_with_overrides(ns_val: hydra.packaging.ModuleName) -> str:
|
|
50
50
|
r"""Convert a ModuleName to its Python dotted import string, routing overlay modules to hydra.overlay.python.*."""
|
|
51
51
|
|
|
52
|
-
return hydra.overlay.python.lib.optionals.
|
|
52
|
+
return hydra.overlay.python.lib.optionals.with_default((lambda : hydra.overlay.python.lib.strings.join(".",
|
|
53
53
|
hydra.overlay.python.lib.lists.map((lambda v1: hydra.formatting.convert_case(hydra.util.CaseConvention.CAMEL, hydra.util.CaseConvention.LOWER_SNAKE, v1)),
|
|
54
54
|
hydra.overlay.python.lib.strings.split_on(".", ns_val.value)))),
|
|
55
55
|
hydra.overlay.python.lib.maps.lookup(ns_val, overlay_python_module_aliases()))
|
|
@@ -84,7 +84,7 @@ name: hydra.core.Name) -> hydra.python.syntax.Name:
|
|
|
84
84
|
(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()))))),
|
|
85
85
|
(lambda : hydra.overlay.python.lib.optionals.cases(mns,
|
|
86
86
|
(lambda : hydra.python.syntax.Name(py_local())),
|
|
87
|
-
(lambda ns_val: hydra.python.syntax.Name(hydra.overlay.python.lib.strings.
|
|
87
|
+
(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())))))))),
|
|
88
88
|
(lambda n: n))),
|
|
89
89
|
(lambda : hydra.python.syntax.Name(py_local())))
|
|
90
90
|
|
|
@@ -115,7 +115,7 @@ def encode_name_qualified(env: hydra.python.environment.PythonEnvironment, name:
|
|
|
115
115
|
(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))))),
|
|
116
116
|
(lambda : hydra.overlay.python.lib.optionals.cases(mns,
|
|
117
117
|
(lambda : hydra.python.syntax.Name(sanitize_python_name(local))),
|
|
118
|
-
(lambda ns_val: hydra.python.syntax.Name(hydra.overlay.python.lib.strings.
|
|
118
|
+
(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))))))))),
|
|
119
119
|
(lambda n: n))
|
|
120
120
|
|
|
121
121
|
def encode_namespace(ns_val: hydra.packaging.ModuleName) -> hydra.python.syntax.DottedName:
|
|
@@ -192,4 +192,4 @@ def variant_name(is_qualified: bool, env: hydra.python.environment.PythonEnviron
|
|
|
192
192
|
return encode_name(is_qualified,
|
|
193
193
|
hydra.util.CaseConvention.PASCAL,
|
|
194
194
|
env,
|
|
195
|
-
hydra.core.Name(hydra.overlay.python.lib.strings.
|
|
195
|
+
hydra.core.Name(hydra.overlay.python.lib.strings.concat2(tname.value, hydra.formatting.capitalize(fname.value))))
|
|
@@ -18,9 +18,9 @@ import hydra.overlay.python.lib.optionals
|
|
|
18
18
|
import hydra.overlay.python.lib.strings
|
|
19
19
|
import hydra.names
|
|
20
20
|
import hydra.packaging
|
|
21
|
+
import hydra.print.docs
|
|
21
22
|
import hydra.python.syntax
|
|
22
23
|
import hydra.serialization
|
|
23
|
-
import hydra.show.docs
|
|
24
24
|
|
|
25
25
|
def compare_op_to_string(op: hydra.python.syntax.CompareOp) -> str:
|
|
26
26
|
r"""Render a Python comparison operator to its source-code form."""
|
|
@@ -90,7 +90,7 @@ def number_to_expr(num: hydra.python.syntax.Number) -> hydra.ast.Expr:
|
|
|
90
90
|
return hydra.serialization.cst(python_float_literal_text(hydra.overlay.python.lib.literals.show_float64(f)))
|
|
91
91
|
|
|
92
92
|
case hydra.python.syntax.NumberImaginary(value=f2):
|
|
93
|
-
return hydra.serialization.cst(hydra.overlay.python.lib.strings.
|
|
93
|
+
return hydra.serialization.cst(hydra.overlay.python.lib.strings.concat2(python_float_literal_text(hydra.overlay.python.lib.literals.show_float64(f2)), "j"))
|
|
94
94
|
|
|
95
95
|
case hydra.python.syntax.NumberInteger(value=i):
|
|
96
96
|
return hydra.serialization.cst(hydra.overlay.python.lib.literals.show_bigint(i))
|
|
@@ -102,7 +102,7 @@ def escape_python_string(double_quoted: bool, s: str) -> str:
|
|
|
102
102
|
r"""Escape special characters in a Python string and wrap in quotes."""
|
|
103
103
|
|
|
104
104
|
def replace(old: str, new: str, str: str) -> str:
|
|
105
|
-
return hydra.overlay.python.lib.strings.
|
|
105
|
+
return hydra.overlay.python.lib.strings.join(new, hydra.overlay.python.lib.strings.split_on(old, str))
|
|
106
106
|
s1 = Lazy((lambda : replace("\\", "\\\\", s)))
|
|
107
107
|
s2 = Lazy((lambda : replace("\x00", "\\x00", s1())))
|
|
108
108
|
s3 = Lazy((lambda : replace("\n", "\\n", s2())))
|
|
@@ -110,7 +110,7 @@ def escape_python_string(double_quoted: bool, s: str) -> str:
|
|
|
110
110
|
s5 = Lazy((lambda : replace("\r", "\\r", s4())))
|
|
111
111
|
escaped = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(double_quoted, (lambda : replace("\"", "\\\"", s5())), (lambda : replace("'", "\\'", s5())))))
|
|
112
112
|
quote = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(double_quoted, (lambda : "\""), (lambda : "'"))))
|
|
113
|
-
return hydra.overlay.python.lib.strings.
|
|
113
|
+
return hydra.overlay.python.lib.strings.concat2(quote(), hydra.overlay.python.lib.strings.concat2(escaped(), quote()))
|
|
114
114
|
|
|
115
115
|
def string_prefix_to_text(p: hydra.python.syntax.StringPrefix) -> str:
|
|
116
116
|
r"""Serialize a Python string prefix to its source-form characters."""
|
|
@@ -139,18 +139,18 @@ def string_to_expr(s: hydra.python.syntax.String) -> hydra.ast.Expr:
|
|
|
139
139
|
style = s.quote_style
|
|
140
140
|
match style:
|
|
141
141
|
case hydra.python.syntax.QuoteStyle.SINGLE:
|
|
142
|
-
return hydra.serialization.cst(hydra.overlay.python.lib.strings.
|
|
142
|
+
return hydra.serialization.cst(hydra.overlay.python.lib.strings.concat2(prefix(), escape_python_string(False, content)))
|
|
143
143
|
|
|
144
144
|
case hydra.python.syntax.QuoteStyle.DOUBLE:
|
|
145
|
-
return hydra.serialization.cst(hydra.overlay.python.lib.strings.
|
|
145
|
+
return hydra.serialization.cst(hydra.overlay.python.lib.strings.concat2(prefix(), escape_python_string(True, content)))
|
|
146
146
|
|
|
147
147
|
case hydra.python.syntax.QuoteStyle.TRIPLE_SINGLE:
|
|
148
|
-
return hydra.serialization.no_sep(ConsList.of(hydra.serialization.cst(hydra.overlay.python.lib.strings.
|
|
148
|
+
return hydra.serialization.no_sep(ConsList.of(hydra.serialization.cst(hydra.overlay.python.lib.strings.concat2(prefix(), "'''")),
|
|
149
149
|
hydra.serialization.cst(content),
|
|
150
150
|
hydra.serialization.cst("'''")))
|
|
151
151
|
|
|
152
152
|
case hydra.python.syntax.QuoteStyle.TRIPLE_DOUBLE:
|
|
153
|
-
return hydra.serialization.no_sep(ConsList.of(hydra.serialization.cst(hydra.overlay.python.lib.strings.
|
|
153
|
+
return hydra.serialization.no_sep(ConsList.of(hydra.serialization.cst(hydra.overlay.python.lib.strings.concat2(prefix(), "\"\"\"")),
|
|
154
154
|
hydra.serialization.cst(content),
|
|
155
155
|
hydra.serialization.cst("\"\"\"")))
|
|
156
156
|
|
|
@@ -243,7 +243,7 @@ def bitwise_and_to_expr(band: hydra.python.syntax.BitwiseAnd) -> hydra.ast.Expr:
|
|
|
243
243
|
|
|
244
244
|
lhs = band.lhs
|
|
245
245
|
rhs = band.rhs
|
|
246
|
-
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.
|
|
246
|
+
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(hydra.overlay.python.lib.optionals.map((lambda l: hydra.serialization.space_sep(ConsList.of(bitwise_and_to_expr(l), hydra.serialization.cst("&")))), lhs),
|
|
247
247
|
Given(shift_expression_to_expr(rhs)))))
|
|
248
248
|
|
|
249
249
|
def bitwise_or_to_expr(bor: hydra.python.syntax.BitwiseOr) -> hydra.ast.Expr:
|
|
@@ -251,7 +251,7 @@ def bitwise_or_to_expr(bor: hydra.python.syntax.BitwiseOr) -> hydra.ast.Expr:
|
|
|
251
251
|
|
|
252
252
|
lhs = bor.lhs
|
|
253
253
|
rhs = bor.rhs
|
|
254
|
-
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.
|
|
254
|
+
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(hydra.overlay.python.lib.optionals.map((lambda l: hydra.serialization.space_sep(ConsList.of(bitwise_or_to_expr(l), hydra.serialization.cst("|")))), lhs),
|
|
255
255
|
Given(bitwise_xor_to_expr(rhs)))))
|
|
256
256
|
|
|
257
257
|
def bitwise_xor_to_expr(bxor: hydra.python.syntax.BitwiseXor) -> hydra.ast.Expr:
|
|
@@ -259,7 +259,7 @@ def bitwise_xor_to_expr(bxor: hydra.python.syntax.BitwiseXor) -> hydra.ast.Expr:
|
|
|
259
259
|
|
|
260
260
|
lhs = bxor.lhs
|
|
261
261
|
rhs = bxor.rhs
|
|
262
|
-
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.
|
|
262
|
+
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(hydra.overlay.python.lib.optionals.map((lambda l: hydra.serialization.space_sep(ConsList.of(bitwise_xor_to_expr(l), hydra.serialization.cst("^")))), lhs),
|
|
263
263
|
Given(bitwise_and_to_expr(rhs)))))
|
|
264
264
|
|
|
265
265
|
def compare_op_bitwise_or_pair_to_expr(pair: hydra.python.syntax.CompareOpBitwiseOrPair) -> hydra.ast.Expr:
|
|
@@ -467,7 +467,7 @@ def power_to_expr(p: hydra.python.syntax.Power) -> hydra.ast.Expr:
|
|
|
467
467
|
|
|
468
468
|
lhs = p.lhs
|
|
469
469
|
rhs = p.rhs
|
|
470
|
-
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.
|
|
470
|
+
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(await_primary_to_expr(lhs)),
|
|
471
471
|
hydra.overlay.python.lib.optionals.map((lambda r: hydra.serialization.space_sep(ConsList.of(hydra.serialization.cst("**"), factor_to_expr(r)))), rhs))))
|
|
472
472
|
|
|
473
473
|
def primary_rhs_to_expr(rhs: hydra.python.syntax.PrimaryRhs) -> hydra.ast.Expr:
|
|
@@ -585,11 +585,11 @@ def tuple_to_expr(t: hydra.python.syntax.Tuple) -> hydra.ast.Expr:
|
|
|
585
585
|
r"""Serialize a Python tuple."""
|
|
586
586
|
|
|
587
587
|
es = t.value
|
|
588
|
-
return hydra.overlay.python.lib.optionals.
|
|
588
|
+
return hydra.overlay.python.lib.optionals.with_default((lambda : hydra.serialization.paren_list_adaptive(hydra.overlay.python.lib.lists.map((lambda x1: star_named_expression_to_expr(x1)), es))),
|
|
589
589
|
hydra.overlay.python.lib.optionals.map((lambda first_es: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(hydra.overlay.python.lib.lists.length(es), 1),
|
|
590
590
|
(lambda : hydra.serialization.parens(hydra.serialization.no_sep(ConsList.of(star_named_expression_to_expr(first_es), hydra.serialization.cst(","))))),
|
|
591
591
|
(lambda : hydra.serialization.paren_list_adaptive(hydra.overlay.python.lib.lists.map((lambda x1: star_named_expression_to_expr(x1)), es))))),
|
|
592
|
-
hydra.overlay.python.lib.lists.
|
|
592
|
+
hydra.overlay.python.lib.lists.head(es)))
|
|
593
593
|
|
|
594
594
|
def star_expression_to_expr(se: hydra.python.syntax.StarExpression) -> hydra.ast.Expr:
|
|
595
595
|
r"""Serialize a star expression."""
|
|
@@ -641,7 +641,7 @@ def typed_assignment_to_expr(ta: hydra.python.syntax.TypedAssignment) -> hydra.a
|
|
|
641
641
|
lhs = ta.lhs
|
|
642
642
|
typ = ta.type
|
|
643
643
|
rhs = ta.rhs
|
|
644
|
-
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.
|
|
644
|
+
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(hydra.serialization.no_sep(ConsList.of(single_target_to_expr(lhs), hydra.serialization.cst(":")))),
|
|
645
645
|
Given(expression_to_expr(typ)),
|
|
646
646
|
hydra.overlay.python.lib.optionals.map((lambda x1: annotated_rhs_to_expr(x1)), rhs))))
|
|
647
647
|
|
|
@@ -748,7 +748,7 @@ def assignment_to_expr(a: hydra.python.syntax.Assignment) -> hydra.ast.Expr:
|
|
|
748
748
|
def dotted_name_to_expr(dn: hydra.python.syntax.DottedName) -> hydra.ast.Expr:
|
|
749
749
|
r"""Serialize a dotted name (e.g., module.submodule)."""
|
|
750
750
|
|
|
751
|
-
return hydra.serialization.cst(hydra.overlay.python.lib.strings.
|
|
751
|
+
return hydra.serialization.cst(hydra.overlay.python.lib.strings.join(".", hydra.overlay.python.lib.lists.map((lambda n: n.value), dn.value)))
|
|
752
752
|
|
|
753
753
|
def import_from_as_name_to_expr(ifan: hydra.python.syntax.ImportFromAsName) -> hydra.ast.Expr:
|
|
754
754
|
r"""Serialize an import from as name."""
|
|
@@ -796,7 +796,7 @@ def import_from_to_expr(if_: hydra.python.syntax.ImportFrom) -> hydra.ast.Expr:
|
|
|
796
796
|
prefixes = if_.prefixes
|
|
797
797
|
name = if_.dotted_name
|
|
798
798
|
targets = if_.targets
|
|
799
|
-
lhs = Lazy((lambda : hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.
|
|
799
|
+
lhs = Lazy((lambda : hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.givens(hydra.overlay.python.lib.lists.concat(ConsList.of(hydra.overlay.python.lib.lists.map((lambda p: Given(relative_import_prefix_to_expr(p))), prefixes),
|
|
800
800
|
ConsList.of(hydra.overlay.python.lib.optionals.map((lambda x1: dotted_name_to_expr(x1)), name))))))))
|
|
801
801
|
return hydra.serialization.space_sep(ConsList.of(hydra.serialization.cst("from"), lhs(), hydra.serialization.cst("import"), import_from_targets_to_expr(targets)))
|
|
802
802
|
|
|
@@ -805,7 +805,7 @@ def dotted_as_name_to_expr(dan: hydra.python.syntax.DottedAsName) -> hydra.ast.E
|
|
|
805
805
|
|
|
806
806
|
name = dan.name
|
|
807
807
|
alias = dan.as_
|
|
808
|
-
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.
|
|
808
|
+
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(dotted_name_to_expr(name)),
|
|
809
809
|
hydra.overlay.python.lib.optionals.map((lambda a: hydra.serialization.space_sep(ConsList.of(hydra.serialization.cst("as"), name_to_expr(a)))), alias))))
|
|
810
810
|
|
|
811
811
|
def import_name_to_expr(in_: hydra.python.syntax.ImportName) -> hydra.ast.Expr:
|
|
@@ -832,13 +832,13 @@ def raise_expression_to_expr(re: hydra.python.syntax.RaiseExpression) -> hydra.a
|
|
|
832
832
|
|
|
833
833
|
expr = re.expression
|
|
834
834
|
from_ = re.from_
|
|
835
|
-
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.
|
|
835
|
+
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(expression_to_expr(expr)),
|
|
836
836
|
hydra.overlay.python.lib.optionals.map((lambda f: hydra.serialization.space_sep(ConsList.of(hydra.serialization.cst("from"), expression_to_expr(f)))), from_))))
|
|
837
837
|
|
|
838
838
|
def raise_statement_to_expr(rs: hydra.python.syntax.RaiseStatement) -> hydra.ast.Expr:
|
|
839
839
|
r"""Serialize a raise statement."""
|
|
840
840
|
|
|
841
|
-
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.
|
|
841
|
+
return hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(hydra.serialization.cst("raise")), hydra.overlay.python.lib.optionals.map((lambda x1: raise_expression_to_expr(x1)), rs.value))))
|
|
842
842
|
|
|
843
843
|
def return_statement_to_expr(rs: hydra.python.syntax.ReturnStatement) -> hydra.ast.Expr:
|
|
844
844
|
r"""Serialize a return statement."""
|
|
@@ -873,7 +873,7 @@ def type_alias_to_expr(ta: hydra.python.syntax.TypeAlias) -> hydra.ast.Expr:
|
|
|
873
873
|
name = ta.name
|
|
874
874
|
tparams = ta.type_params
|
|
875
875
|
expr = ta.expression
|
|
876
|
-
alias = Lazy((lambda : hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.
|
|
876
|
+
alias = Lazy((lambda : hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(name_to_expr(name)),
|
|
877
877
|
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.null(tparams),
|
|
878
878
|
(lambda : None_()),
|
|
879
879
|
(lambda : Given(hydra.serialization.bracket_list(hydra.serialization.inline_style, hydra.overlay.python.lib.lists.map((lambda x1: type_parameter_to_expr(x1)), tparams))))))))))
|
|
@@ -941,7 +941,7 @@ def param_to_expr(p: hydra.python.syntax.Param) -> hydra.ast.Expr:
|
|
|
941
941
|
|
|
942
942
|
name = p.name
|
|
943
943
|
ann = p.annotation
|
|
944
|
-
return hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.
|
|
944
|
+
return hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(name_to_expr(name)), hydra.overlay.python.lib.optionals.map((lambda x1: annotation_to_expr(x1)), ann))))
|
|
945
945
|
|
|
946
946
|
def param_no_default_to_expr(pnd: hydra.python.syntax.ParamNoDefault) -> hydra.ast.Expr:
|
|
947
947
|
r"""Serialize a parameter without default."""
|
|
@@ -1006,7 +1006,7 @@ def class_pattern_to_expr(cp: hydra.python.syntax.ClassPattern) -> hydra.ast.Exp
|
|
|
1006
1006
|
noa = cp.name_or_attribute
|
|
1007
1007
|
pos = cp.positional_patterns
|
|
1008
1008
|
kw = cp.keyword_patterns
|
|
1009
|
-
return hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.
|
|
1009
|
+
return hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(name_or_attribute_to_expr(noa)),
|
|
1010
1010
|
Given(hydra.serialization.cst("(")),
|
|
1011
1011
|
hydra.overlay.python.lib.optionals.map((lambda x1: positional_patterns_to_expr(x1)), pos),
|
|
1012
1012
|
hydra.overlay.python.lib.optionals.map((lambda x1: keyword_patterns_to_expr(x1)), kw),
|
|
@@ -1110,13 +1110,13 @@ def python_doc_entity_ref(ref: hydra.packaging.EntityReference) -> str:
|
|
|
1110
1110
|
def _hoist_hydra_python_serde_python_doc_entity_ref_1(v1):
|
|
1111
1111
|
match v1:
|
|
1112
1112
|
case hydra.packaging.DefinitionReferencePrimitive(value=n):
|
|
1113
|
-
return hydra.overlay.python.lib.strings.
|
|
1113
|
+
return hydra.overlay.python.lib.strings.concat2(":func:`", hydra.overlay.python.lib.strings.concat2(hydra.names.local_name_of(n), "`"))
|
|
1114
1114
|
|
|
1115
1115
|
case hydra.packaging.DefinitionReferenceTerm(value=n):
|
|
1116
|
-
return hydra.overlay.python.lib.strings.
|
|
1116
|
+
return hydra.overlay.python.lib.strings.concat2(":func:`", hydra.overlay.python.lib.strings.concat2(hydra.names.local_name_of(n), "`"))
|
|
1117
1117
|
|
|
1118
1118
|
case hydra.packaging.DefinitionReferenceType(value=n):
|
|
1119
|
-
return hydra.overlay.python.lib.strings.
|
|
1119
|
+
return hydra.overlay.python.lib.strings.concat2(":class:`", hydra.overlay.python.lib.strings.concat2(hydra.names.local_name_of(n), "`"))
|
|
1120
1120
|
|
|
1121
1121
|
case _:
|
|
1122
1122
|
raise AssertionError("Unreachable: all variants handled")
|
|
@@ -1125,16 +1125,16 @@ def python_doc_entity_ref(ref: hydra.packaging.EntityReference) -> str:
|
|
|
1125
1125
|
return _hoist_hydra_python_serde_python_doc_entity_ref_1(d)
|
|
1126
1126
|
|
|
1127
1127
|
case hydra.packaging.EntityReferenceModule(value=m):
|
|
1128
|
-
return hydra.overlay.python.lib.strings.
|
|
1128
|
+
return hydra.overlay.python.lib.strings.concat2("", m.value)
|
|
1129
1129
|
|
|
1130
1130
|
case hydra.packaging.EntityReferencePackage(value=p):
|
|
1131
|
-
return hydra.overlay.python.lib.strings.
|
|
1131
|
+
return hydra.overlay.python.lib.strings.concat2("", p.value)
|
|
1132
1132
|
|
|
1133
1133
|
case hydra.packaging.EntityReferenceTermExpr(value=s):
|
|
1134
|
-
return hydra.overlay.python.lib.strings.
|
|
1134
|
+
return hydra.overlay.python.lib.strings.concat2("``", hydra.overlay.python.lib.strings.concat2(s, "``"))
|
|
1135
1135
|
|
|
1136
1136
|
case hydra.packaging.EntityReferenceTypeExpr(value=s2):
|
|
1137
|
-
return hydra.overlay.python.lib.strings.
|
|
1137
|
+
return hydra.overlay.python.lib.strings.concat2("``", hydra.overlay.python.lib.strings.concat2(s2, "``"))
|
|
1138
1138
|
|
|
1139
1139
|
case _:
|
|
1140
1140
|
raise AssertionError("Unreachable: all variants handled")
|
|
@@ -1144,9 +1144,9 @@ def to_python_comments(doc_: str) -> str:
|
|
|
1144
1144
|
|
|
1145
1145
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(doc_, ""),
|
|
1146
1146
|
(lambda : ""),
|
|
1147
|
-
(lambda : hydra.overlay.python.lib.strings.
|
|
1148
|
-
hydra.overlay.python.lib.lists.map((lambda line: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(line, ""), (lambda : "#"), (lambda : hydra.overlay.python.lib.strings.
|
|
1149
|
-
hydra.overlay.python.lib.strings.lines(hydra.
|
|
1147
|
+
(lambda : hydra.overlay.python.lib.strings.join("\n",
|
|
1148
|
+
hydra.overlay.python.lib.lists.map((lambda line: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(line, ""), (lambda : "#"), (lambda : hydra.overlay.python.lib.strings.concat2("# ", line)))),
|
|
1149
|
+
hydra.overlay.python.lib.strings.lines(hydra.print.docs.render_doc_string_with((lambda x1: python_doc_entity_ref(x1)), doc_))))))
|
|
1150
1150
|
|
|
1151
1151
|
def annotated_statement_to_expr(as_: hydra.python.syntax.AnnotatedStatement) -> hydra.ast.Expr:
|
|
1152
1152
|
r"""Serialize an annotated statement (with optional doc comment)."""
|
|
@@ -1174,7 +1174,7 @@ def case_block_to_expr(cb: hydra.python.syntax.CaseBlock) -> hydra.ast.Expr:
|
|
|
1174
1174
|
patterns = cb.patterns
|
|
1175
1175
|
guard = cb.guard
|
|
1176
1176
|
body = cb.body
|
|
1177
|
-
return hydra.serialization.newline_sep(ConsList.of(hydra.serialization.no_sep(ConsList.of(hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.
|
|
1177
|
+
return hydra.serialization.newline_sep(ConsList.of(hydra.serialization.no_sep(ConsList.of(hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(hydra.serialization.cst("case")),
|
|
1178
1178
|
Given(patterns_to_expr(patterns)),
|
|
1179
1179
|
hydra.overlay.python.lib.optionals.map((lambda x1: guard_to_expr(x1)), guard)))),
|
|
1180
1180
|
hydra.serialization.cst(":"))),
|
|
@@ -1189,8 +1189,8 @@ def class_definition_to_expr(cd: hydra.python.syntax.ClassDefinition) -> hydra.a
|
|
|
1189
1189
|
body = cd.body
|
|
1190
1190
|
arg_part = Lazy((lambda : hydra.overlay.python.lib.optionals.map((lambda a: hydra.serialization.no_sep(ConsList.of(hydra.serialization.cst("("), args_to_expr(a), hydra.serialization.cst(")")))),
|
|
1191
1191
|
args)))
|
|
1192
|
-
return hydra.serialization.newline_sep(hydra.overlay.python.lib.optionals.
|
|
1193
|
-
Given(hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.
|
|
1192
|
+
return hydra.serialization.newline_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(hydra.overlay.python.lib.optionals.map((lambda x1: decorators_to_expr(x1)), decs),
|
|
1193
|
+
Given(hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(hydra.serialization.space_sep(ConsList.of(hydra.serialization.cst("class"), name_to_expr(name)))),
|
|
1194
1194
|
arg_part(),
|
|
1195
1195
|
Given(hydra.serialization.cst(":")))))),
|
|
1196
1196
|
Given(block_to_expr(body)))))
|
|
@@ -1241,9 +1241,9 @@ def function_def_raw_to_expr(fdr: hydra.python.syntax.FunctionDefRaw) -> hydra.a
|
|
|
1241
1241
|
(lambda : Given(hydra.serialization.bracket_list(hydra.serialization.inline_style, hydra.overlay.python.lib.lists.map((lambda x1: type_parameter_to_expr(x1)), tparams)))))))
|
|
1242
1242
|
param_part = Lazy((lambda : hydra.overlay.python.lib.optionals.map((lambda x1: parameters_to_expr(x1)), params)))
|
|
1243
1243
|
ret_part = Lazy((lambda : hydra.overlay.python.lib.optionals.map((lambda t: hydra.serialization.space_sep(ConsList.of(hydra.serialization.cst("->"), expression_to_expr(t)))), ret_type)))
|
|
1244
|
-
return hydra.serialization.newline_sep(ConsList.of(hydra.serialization.no_sep(ConsList.of(hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.
|
|
1244
|
+
return hydra.serialization.newline_sep(ConsList.of(hydra.serialization.no_sep(ConsList.of(hydra.serialization.space_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(async_kw(),
|
|
1245
1245
|
Given(hydra.serialization.cst("def")),
|
|
1246
|
-
Given(hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.
|
|
1246
|
+
Given(hydra.serialization.no_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(name_to_expr(name)),
|
|
1247
1247
|
tparam_part(),
|
|
1248
1248
|
Given(hydra.serialization.cst("(")),
|
|
1249
1249
|
param_part(),
|
|
@@ -1257,7 +1257,7 @@ def function_definition_to_expr(fd: hydra.python.syntax.FunctionDefinition) -> h
|
|
|
1257
1257
|
|
|
1258
1258
|
decs = fd.decorators
|
|
1259
1259
|
raw = fd.raw
|
|
1260
|
-
return hydra.serialization.newline_sep(hydra.overlay.python.lib.optionals.
|
|
1260
|
+
return hydra.serialization.newline_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(hydra.overlay.python.lib.optionals.map((lambda x1: decorators_to_expr(x1)), decs), Given(function_def_raw_to_expr(raw)))))
|
|
1261
1261
|
|
|
1262
1262
|
def match_statement_to_expr(ms: hydra.python.syntax.MatchStatement) -> hydra.ast.Expr:
|
|
1263
1263
|
r"""Serialize a match statement."""
|
|
@@ -1290,7 +1290,7 @@ def while_statement_to_expr(ws: hydra.python.syntax.WhileStatement) -> hydra.ast
|
|
|
1290
1290
|
cond = ws.condition
|
|
1291
1291
|
body = ws.body
|
|
1292
1292
|
else_ = ws.else_
|
|
1293
|
-
return hydra.serialization.newline_sep(hydra.overlay.python.lib.optionals.
|
|
1293
|
+
return hydra.serialization.newline_sep(hydra.overlay.python.lib.optionals.givens(ConsList.of(Given(hydra.serialization.newline_sep(ConsList.of(hydra.serialization.space_sep(ConsList.of(hydra.serialization.cst("while"),
|
|
1294
1294
|
hydra.serialization.no_sep(ConsList.of(named_expression_to_expr(cond), hydra.serialization.cst(":"))))),
|
|
1295
1295
|
block_to_expr(body)))),
|
|
1296
1296
|
hydra.overlay.python.lib.optionals.map((lambda eb: hydra.serialization.newline_sep(ConsList.of(hydra.serialization.cst("else:"), block_to_expr(eb)))), else_))))
|
|
@@ -27,16 +27,16 @@ def build_python_test_module(test_module: T0, test_group: hydra.testing.TestGrou
|
|
|
27
27
|
r"""Build the complete Python test module content."""
|
|
28
28
|
|
|
29
29
|
group_name_ = test_group.name
|
|
30
|
-
header = Lazy((lambda : hydra.overlay.python.lib.strings.
|
|
30
|
+
header = Lazy((lambda : hydra.overlay.python.lib.strings.concat(ConsList.of(hydra.overlay.python.lib.strings.concat2("# ", hydra.constants.warning_auto_generated_file),
|
|
31
31
|
"\n",
|
|
32
|
-
hydra.overlay.python.lib.strings.
|
|
32
|
+
hydra.overlay.python.lib.strings.concat2("# ", group_name_),
|
|
33
33
|
"\n\n"))))
|
|
34
|
-
return hydra.overlay.python.lib.strings.
|
|
34
|
+
return hydra.overlay.python.lib.strings.concat(ConsList.of(header(), test_body, "\n"))
|
|
35
35
|
|
|
36
36
|
def format_python_test_name(name: str) -> str:
|
|
37
37
|
r"""Format a test name for Python (snake_case with test_ prefix)."""
|
|
38
38
|
|
|
39
|
-
return hydra.overlay.python.lib.strings.
|
|
39
|
+
return hydra.overlay.python.lib.strings.concat2("test_",
|
|
40
40
|
hydra.overlay.python.lib.strings.from_list(hydra.overlay.python.lib.lists.map((lambda c: hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.chars.is_alpha_num(c), (lambda : hydra.overlay.python.lib.chars.to_lower(c)), (lambda : 95))),
|
|
41
41
|
hydra.overlay.python.lib.strings.to_list(name))))
|
|
42
42
|
|
|
@@ -51,10 +51,10 @@ def generate_python_test_case(group_path: Sequence[str], tcm: hydra.testing.Test
|
|
|
51
51
|
expected_ = Lazy((lambda : ucase.expected(None)))
|
|
52
52
|
full_name = Lazy((lambda : hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.lists.null(group_path),
|
|
53
53
|
(lambda : name_),
|
|
54
|
-
(lambda : hydra.overlay.python.lib.strings.
|
|
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())))
|
|
56
|
-
return Right(ConsList.of(hydra.overlay.python.lib.strings.
|
|
57
|
-
hydra.overlay.python.lib.strings.
|
|
56
|
+
return Right(ConsList.of(hydra.overlay.python.lib.strings.concat(ConsList.of("def ", formatted_name(), "():")),
|
|
57
|
+
hydra.overlay.python.lib.strings.concat(ConsList.of(" assert (", actual_(), ") == (", expected_(), ")"))))
|
|
58
58
|
|
|
59
59
|
case _:
|
|
60
60
|
raise TypeError("Unsupported TestCase")
|
|
@@ -67,14 +67,14 @@ def generate_python_test_group_hierarchy(group_path: Sequence[str], test_group:
|
|
|
67
67
|
return hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.eithers.map_list((lambda tc: generate_python_test_case(group_path, tc)), cases_),
|
|
68
68
|
(lambda test_case_lines: hydra.overlay.python.lib.eithers.bind(hydra.overlay.python.lib.eithers.map_list((lambda subgroup: (
|
|
69
69
|
group_name := Lazy((lambda : subgroup.name)),
|
|
70
|
-
header := Lazy((lambda : hydra.overlay.python.lib.strings.
|
|
71
|
-
hydra.overlay.python.lib.eithers.map((lambda content: hydra.overlay.python.lib.strings.
|
|
70
|
+
header := Lazy((lambda : hydra.overlay.python.lib.strings.concat2("# ", group_name.get()))),
|
|
71
|
+
hydra.overlay.python.lib.eithers.map((lambda content: hydra.overlay.python.lib.strings.concat(ConsList.of(header.get(), "\n\n", content))),
|
|
72
72
|
generate_python_test_group_hierarchy(hydra.overlay.python.lib.lists.concat2(group_path, ConsList.of(group_name.get())), subgroup)))[2]),
|
|
73
73
|
subgroups),
|
|
74
74
|
(lambda subgroup_blocks: (
|
|
75
|
-
test_cases_str := Lazy((lambda : hydra.overlay.python.lib.strings.
|
|
76
|
-
subgroups_str := Lazy((lambda : hydra.overlay.python.lib.strings.
|
|
77
|
-
Right(hydra.overlay.python.lib.strings.
|
|
75
|
+
test_cases_str := Lazy((lambda : hydra.overlay.python.lib.strings.join("\n\n", hydra.overlay.python.lib.lists.concat(test_case_lines)))),
|
|
76
|
+
subgroups_str := Lazy((lambda : hydra.overlay.python.lib.strings.join("\n\n", subgroup_blocks))),
|
|
77
|
+
Right(hydra.overlay.python.lib.strings.concat(ConsList.of(test_cases_str.get(),
|
|
78
78
|
hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.logic.or_(hydra.overlay.python.lib.equality.equal(test_cases_str.get(), ""), hydra.overlay.python.lib.equality.equal(subgroups_str.get(), "")),
|
|
79
79
|
(lambda : ""),
|
|
80
80
|
(lambda : "\n\n")),
|
|
@@ -87,9 +87,9 @@ def generate_test_file_with_python_codec(test_module: hydra.packaging.Module, te
|
|
|
87
87
|
test_module_content := Lazy((lambda : build_python_test_module(test_module, test_group, test_body))),
|
|
88
88
|
ns_ := Lazy((lambda : test_module.name)),
|
|
89
89
|
parts := Lazy((lambda : hydra.overlay.python.lib.strings.split_on(".", ns_.get().value))),
|
|
90
|
-
dir_parts := Lazy((lambda : hydra.overlay.python.lib.optionals.
|
|
91
|
-
file_name := Lazy((lambda : hydra.overlay.python.lib.strings.
|
|
92
|
-
file_path := Lazy((lambda : hydra.overlay.python.lib.strings.
|
|
90
|
+
dir_parts := Lazy((lambda : hydra.overlay.python.lib.optionals.with_default((lambda : ConsList.of()), hydra.overlay.python.lib.lists.init(parts.get())))),
|
|
91
|
+
file_name := Lazy((lambda : hydra.overlay.python.lib.strings.concat(ConsList.of("test_", hydra.overlay.python.lib.optionals.with_default((lambda : ""), hydra.overlay.python.lib.lists.last(parts.get())), ".py")))),
|
|
92
|
+
file_path := Lazy((lambda : hydra.overlay.python.lib.strings.concat(ConsList.of(hydra.overlay.python.lib.strings.join("/", dir_parts.get()), "/", file_name.get())))),
|
|
93
93
|
(file_path.get(), test_module_content.get()))[6]),
|
|
94
94
|
generate_python_test_group_hierarchy(ConsList.of(), test_group))
|
|
95
95
|
|
|
@@ -96,7 +96,7 @@ def py_expression_to_py_slice(expr: hydra.python.syntax.Expression) -> hydra.pyt
|
|
|
96
96
|
def primary_with_expression_slices(prim: hydra.python.syntax.Primary, exprs: Sequence[hydra.python.syntax.Expression]) -> hydra.python.syntax.Primary:
|
|
97
97
|
r"""Create a Primary with expression slices."""
|
|
98
98
|
|
|
99
|
-
return hydra.overlay.python.lib.optionals.
|
|
99
|
+
return hydra.overlay.python.lib.optionals.with_default((lambda : prim),
|
|
100
100
|
hydra.overlay.python.lib.optionals.map((lambda p: primary_with_slices(prim,
|
|
101
101
|
py_expression_to_py_slice(hydra.overlay.python.lib.pairs.first(p)),
|
|
102
102
|
hydra.overlay.python.lib.lists.map((lambda e: cast(hydra.python.syntax.SliceOrStarredExpression,
|
|
@@ -258,7 +258,7 @@ def decode_py_conjunction_to_py_primary(c: hydra.python.syntax.Conjunction) -> O
|
|
|
258
258
|
|
|
259
259
|
inversions = c.value
|
|
260
260
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(hydra.overlay.python.lib.lists.length(inversions), 1),
|
|
261
|
-
(lambda : hydra.overlay.python.lib.optionals.bind(hydra.overlay.python.lib.lists.
|
|
261
|
+
(lambda : hydra.overlay.python.lib.optionals.bind(hydra.overlay.python.lib.lists.head(inversions), (lambda i: decode_py_inversion_to_py_primary(i)))),
|
|
262
262
|
(lambda : None_()))
|
|
263
263
|
|
|
264
264
|
def decode_py_expression_to_py_primary(e: hydra.python.syntax.Expression) -> Optional[hydra.python.syntax.Primary]:
|
|
@@ -268,7 +268,7 @@ def decode_py_expression_to_py_primary(e: hydra.python.syntax.Expression) -> Opt
|
|
|
268
268
|
case hydra.python.syntax.ExpressionSimple(value=disj):
|
|
269
269
|
conjunctions = disj.value
|
|
270
270
|
return hydra.overlay.python.lib.logic.if_else(hydra.overlay.python.lib.equality.equal(hydra.overlay.python.lib.lists.length(conjunctions), 1),
|
|
271
|
-
(lambda : hydra.overlay.python.lib.optionals.bind(hydra.overlay.python.lib.lists.
|
|
271
|
+
(lambda : hydra.overlay.python.lib.optionals.bind(hydra.overlay.python.lib.lists.head(conjunctions), (lambda c2: decode_py_conjunction_to_py_primary(c2)))),
|
|
272
272
|
(lambda : None_()))
|
|
273
273
|
|
|
274
274
|
case _:
|
|
@@ -546,7 +546,7 @@ extra_stmts: Sequence[hydra.python.syntax.Statement]) -> Sequence[hydra.python.s
|
|
|
546
546
|
r"""Generate a subscriptable union class for Python 3.10."""
|
|
547
547
|
|
|
548
548
|
name_str = name.value
|
|
549
|
-
meta_name = Lazy((lambda : hydra.python.syntax.Name(hydra.overlay.python.lib.strings.
|
|
549
|
+
meta_name = Lazy((lambda : hydra.python.syntax.Name(hydra.overlay.python.lib.strings.concat2(hydra.overlay.python.lib.strings.concat2("_", name_str), "Meta"))))
|
|
550
550
|
doc_string = Lazy((lambda : hydra.serialization.print_expr(hydra.python.serde.expression_to_expr(tyexpr))))
|
|
551
551
|
return_object = Lazy((lambda : py_simple_statement_to_py_statement(cast(hydra.python.syntax.SimpleStatement,
|
|
552
552
|
hydra.python.syntax.SimpleStatementReturn(hydra.python.syntax.ReturnStatement(ConsList.of(cast(hydra.python.syntax.StarExpression,
|
|
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
|