Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
We got pretty close to having TypedDicts for river-python inputs before, but had to roll back due to a protocol mismatch.
Trying again, and also adding some tests to confirm that at the very least the Pydantic models can decode was was encoded by the TypedDict encoders. It's not a perfect science, but it should be good enough to start building more confidence as we make additional progress.
The reason for "janky" tests
There's a bit of a chicken-and-egg situation when trying to test code generation at runtime.
We have three options:
gen1
,gen2
,gen3
, one for each codegen run necessary) and carefully juggle the imports to make sure we don't try to import something that's not there yet. This might be the best option, but I'm not convinced about the ergonomics at the moment. It might be OK though, with highly targeted.gitignore
's.I definitely wrote the tests here in a way that would give some coverage and also provide confidence, while intentionally deferring the above decision so we can keep making progress. in the meantime.
What changed
Test plan