datamodel-code-generator
datamodel-code-generator copied to clipboard
Fix --use-annotated for pydantic v2
- Fixes two bugs for pydantic v2 --use-annotated:
- incorrect default value for optional lists
- incorrect default value "style" for Annotated fields:
default value style before the fix:
fieldname: Annotated[<type>, Field(<default>, <kwargs>)]the correct style, after the fix:fieldname: Annotated[<type>, Field(<kwargs>)] = <default>
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 100.00%. Comparing base (
010c72b) to head (99b680d). Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #2033 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 38 38
Lines 4211 4201 -10
Branches 978 976 -2
=========================================
- Hits 4211 4201 -10
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 99.66% <100.00%> (-0.01%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
CodSpeed Performance Report
Merging #2033 will improve performances by 49.72%
Comparing bpsoos:fix-annotated (99b680d) with main (010c72b)
Summary
⚡ 24 improvements
✅ 7 untouched benchmarks
Benchmarks breakdown
| Benchmark | main |
bpsoos:fix-annotated |
Change | |
|---|---|---|---|---|
| ⚡ | test_main_autodetect |
72.6 ms | 64.2 ms | +13.09% |
| ⚡ | test_main_inheritance_forward_ref |
138.2 ms | 105.6 ms | +30.89% |
| ⚡ | test_main_inheritance_forward_ref_keep_model_order |
139.7 ms | 104.1 ms | +34.14% |
| ⚡ | test_main_json_reuse_enum_default_member |
99.1 ms | 75.5 ms | +31.35% |
| ⚡ | test_main_jsonschema_collapsed_external_references |
95.6 ms | 82.4 ms | +16% |
| ⚡ | test_main_jsonschema_complex_any_of |
72.6 ms | 63.3 ms | +14.73% |
| ⚡ | test_main_jsonschema_field_include_all_keys |
71.2 ms | 61.5 ms | +15.89% |
| ⚡ | test_main_jsonschema_multiple_files |
94.9 ms | 83.6 ms | +13.57% |
| ⚡ | test_main_jsonschema_nested_deep |
85.8 ms | 73.5 ms | +16.8% |
| ⚡ | test_main_jsonschema_special_field_name |
74 ms | 64.9 ms | +14.09% |
| ⚡ | test_main_nested_directory |
279.9 ms | 198.4 ms | +41.11% |
| ⚡ | test_main_root_id_jsonschema_self_refs_with_local_file |
100 ms | 82.7 ms | +20.85% |
| ⚡ | test_main_root_id_jsonschema_self_refs_with_remote_file |
100.1 ms | 82.6 ms | +21.15% |
| ⚡ | test_main_strict_types |
93.3 ms | 75.1 ms | +24.21% |
| ⚡ | test_main_strict_types_all_with_field_constraints |
88.4 ms | 71.4 ms | +23.71% |
| ⚡ | test_force_optional |
161.3 ms | 116.6 ms | +38.38% |
| ⚡ | test_main |
147.5 ms | 108.2 ms | +36.33% |
| ⚡ | test_main_collapse_root_models |
98.4 ms | 78.5 ms | +25.4% |
| ⚡ | test_main_modular |
359.9 ms | 240.4 ms | +49.72% |
| ⚡ | test_main_openapi_nullable |
175.1 ms | 120 ms | +45.9% |
| ... | ... | ... | ... | ... |
:information_source: Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.
Hi @koxudaxi,
Thanks for the review! I addressed above the change you were concerned about. Let me know what you think!
Looks good :) Thank you very much!!