-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pydanticgen] Simplify pydantic generator render method #2019
base: main
Are you sure you want to change the base?
[pydanticgen] Simplify pydantic generator render method #2019
Conversation
In fixing the failing test, i both noticed that the test was a string comparison test and that the test seems to be incorrect. Stems from #1094 The model in question has a slot formerly, the test produced a field annotation like this: bikes: Dict[str, str] = Field(default_factory=dict) but that would allow a model to be instantiated without The annotation is also too general - it shouldn't be a dictionary of strings, but a dictionary of The correct annotation, i think, should be: bikes: Dict[str, Union[str, Bike]] = Field(...) so I updated the code and the test to match, and also added a test for list inlining. This should generally be true, right?
|
…issing pydantic compliance tests, make test fail if no condition present
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2019 +/- ##
==========================================
+ Coverage 79.88% 79.90% +0.02%
==========================================
Files 109 109
Lines 12249 12252 +3
Branches 3489 3486 -3
==========================================
+ Hits 9785 9790 +5
+ Misses 1874 1873 -1
+ Partials 590 589 -1 ☔ View full report in Codecov by Sentry. |
…dd array generation back in. Remove "Annotation" object and replace with plain string
…stressingly still existent output chaff
This PR also:
|
tests pass - bump on reviewing this, this is a blocker for #2036 and other future planned improvements to pydantic generator. basically a tech debt PR that makes few if any changes to behavior, just cleaning up code, breaking it up into discrete sections, reducing the amount of implicit mutation in place, etc. once this is merged i'll keep working on #2036 :) |
Part of a continuing series of refactoring the pydanticgen.
Should not be merged until:
When last we left it in #1927 i had made a mess at the bottom of the serialization method casting the previous serialization method result into the new template models.
This PR refactors the serialization method into a
generate_class
andgenerate_slot
method, splitting up the logic that was all sorta piled up in the serialization method.I also started transforming some of the
get
methods into properties, since we want to minimized repeated calls toinduced_slots
as much as we possibly can, and those should need to only be computed once and have a static result (ie. be properties not methods).Quite a ways to go yet, but another incremental step there :)