koxudaxi
datamodel-code-generator
BlogDocsChangelog

fix: move UnionMode import outside TYPE_CHECKING for Pydantic runtime…

#2950
Comparing
phil65:fix/unionmode-type-checking-import
(
fa175a7
) with
main
(
4decf36
)
CodSpeed Performance Gauge
-15%
Regressions
11
Skipped
98

Benchmarks

Skipped (98)

Failed

test_perf_duplicate_names
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-15%
842.7 ms988.2 ms
test_perf_deep_nested
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-13%
5.2 s5.9 s
test_perf_kubernetes_style_pydantic_v2
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-15%
2.2 s2.6 s
test_perf_aws_style_openapi_pydantic_v2
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-13%
1.7 s1.9 s
test_perf_graphql_style_pydantic_v2
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-13%
705 ms809.8 ms
test_perf_complex_refs
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-12%
1.8 s2 s
test_perf_multiple_files_input
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-15%
3.2 s3.8 s
test_perf_stripe_style_pydantic_v2
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-14%
1.7 s1.9 s
test_perf_all_options_enabled
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-14%
5.8 s6.7 s
test_perf_openapi_large
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-14%
2.5 s2.9 s
test_perf_large_models_pydantic_v2
tests/main/test_performance.py
Regression
CodSpeed Performance Gauge
-15%
3.1 s3.6 s

Commits

Click on a commit to change the comparison range
Base
main
4decf36
-15.48%
fix: move UnionMode import outside TYPE_CHECKING for Pydantic runtime access The UnionMode type is used in GenerateConfig.union_mode field annotation. Pydantic needs to access this type at runtime for model validation, but it was only imported inside TYPE_CHECKING block, causing: PydanticUserError: GenerateConfig is not fully defined; you should define UnionMode, then call GenerateConfig.model_rebuild(). This follows the same pattern as other runtime-required imports in this file (Path, DataModel, DataModelFieldBase, etc.) which have noqa: TC001 comments.
fa175a7
2 days ago
by phil65
Ā© 2026 CodSpeed Technology
Home Terms Privacy Docs