Commit 483ee7d
Minor refactoring of PyDABs autogen code (#6575)
## Summary
Minor follow-up refactoring on the PyDABs autogen code, addressing
non-blocking review comments left on earlier PRs (#6421, #6528).
## Details
- **Guard `generate_type` against unsupported map refs**: only
`dict[str, str]` is modelled today; any other map ref (`map/int`,
`map/<object>`) previously fell through and silently generated the bare
value type instead of a dict. It now fails loudly, matching the existing
guard in `generated_test_cases._synth_ref`.
- **Remove the dead `create_func_type_name` / `create_func_default`
fields** (and the now-orphaned `optional_type` helper): scaffolding for
a static `create()` factory that was never implemented — set but never
read since codegen was first added.
- **De-duplicate `generate_field`**: collapse the four near-duplicate
`GeneratedField(...)` branches into one base value plus per-branch
`dataclasses.replace(...)` deltas.
- **Rename `TestCase` → `ResourceTestCase`**: pytest no longer tries to
collect it as a test class (its name no longer starts with `Test`), so
the `__test__ = False` marker is unnecessary. The rename propagates
through `test_case.py.tmpl` into `test_resources.py` and the generated
per-resource files.
- **Avoid a `KeyError` on an unknown launch stage**: use
`_STAGE_RANK.get(prop.stage, 0)` instead of a bare dict lookup, so an
absent/unknown stage is treated as GA rather than killing codegen
(matches the Go `launchStageRank` semantics).
- **De-duplicate module resolution**: route `_synth_ref`'s module lookup
through `_module_of` to drop the duplicated `get_package(...) + assert`
logic.
All changes are behavior-preserving: regenerating the PyDABs output
produces a byte-identical tree (aside from the `ResourceTestCase` rename
propagating into the generated files). Codegen unit tests (38) and
`test_resources.py` (232) pass.
Supersedes #6573 (auto-closed when the stack it was based on merged to
`main`).
This pull request and its description were written by Isaac.
---------
Co-authored-by: Isaac <no-reply@databricks.com>1 parent e7d45a7 commit 483ee7d
32 files changed
Lines changed: 92 additions & 145 deletions
File tree
- python
- codegen
- codegen_tests
- codegen
- databricks_tests/core
- _generated
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 68 | | |
77 | 69 | | |
78 | 70 | | |
| |||
83 | 75 | | |
84 | 76 | | |
85 | 77 | | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 78 | | |
95 | 79 | | |
96 | 80 | | |
| |||
151 | 135 | | |
152 | 136 | | |
153 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
154 | 151 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 152 | + | |
167 | 153 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
| 154 | + | |
180 | 155 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 156 | + | |
206 | 157 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 158 | + | |
214 | 159 | | |
215 | 160 | | |
216 | 161 | | |
| |||
281 | 226 | | |
282 | 227 | | |
283 | 228 | | |
284 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
285 | 235 | | |
286 | 236 | | |
287 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
164 | | - | |
| 163 | + | |
165 | 164 | | |
166 | 165 | | |
167 | 166 | | |
| |||
208 | 207 | | |
209 | 208 | | |
210 | 209 | | |
211 | | - | |
| 210 | + | |
212 | 211 | | |
213 | 212 | | |
214 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments