Avatar for the koxudaxi user
koxudaxi
datamodel-code-generator
BlogDocsChangelog

dataclass: Add support for const fields using Literal[T]

#2486
Comparing
ysndr:dataclass-const-as-literal
(
f3200df
) with
main
(
d88bc97
)
CodSpeed Performance Gauge
0%
Improvements
0
Regressions
0
Untouched
32
New
0
Dropped
0
Ignored
0

Benchmarks

Passed

test_main_with_strip_default_none
tests/main/openapi/test_main_openapi.py::test_main_with_strip_default_none
CodSpeed Performance Gauge
0%
110.7 ms
110.4 ms
test_force_optional
tests/main/openapi/test_main_openapi.py::test_force_optional
CodSpeed Performance Gauge
0%
118.8 ms
118.7 ms
test_main_jsonschema_collapsed_external_references
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_collapsed_external_references
CodSpeed Performance Gauge
0%
77.1 ms
77 ms
test_main_strict_types
tests/main/jsonschema/test_main_jsonschema.py::test_main_strict_types
CodSpeed Performance Gauge
0%
73.5 ms
73.4 ms
test_main_modular
tests/main/openapi/test_main_openapi.py::test_main_modular
CodSpeed Performance Gauge
0%
242.8 ms
242.7 ms
test_main_json_reuse_enum_default_member
tests/main/jsonschema/test_main_jsonschema.py::test_main_json_reuse_enum_default_member
CodSpeed Performance Gauge
0%
74.8 ms
74.7 ms
test_main_autodetect
tests/main/jsonschema/test_main_jsonschema.py::test_main_autodetect
CodSpeed Performance Gauge
0%
62.2 ms
62.2 ms
test_main_jsonschema_field_include_all_keys
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_field_include_all_keys
CodSpeed Performance Gauge
0%
60.2 ms
60.1 ms
test_main_root_id_jsonschema_self_refs_with_remote_file
tests/main/jsonschema/test_main_jsonschema.py::test_main_root_id_jsonschema_self_refs_with_remote_file
CodSpeed Performance Gauge
0%
81.2 ms
81.1 ms
test_main_yaml
tests/main/test_main_yaml.py::test_main_yaml
CodSpeed Performance Gauge
0%
50.5 ms
50.5 ms
test_main_jsonschema_external_files
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_external_files
CodSpeed Performance Gauge
0%
52 ms
52 ms
test_main
tests/main/openapi/test_main_openapi.py::test_main
CodSpeed Performance Gauge
0%
111.6 ms
111.6 ms
test_main_inheritance_forward_ref_keep_model_order
tests/main/jsonschema/test_main_jsonschema.py::test_main_inheritance_forward_ref_keep_model_order
CodSpeed Performance Gauge
0%
100.9 ms
100.9 ms
test_main_inheritance_forward_ref
tests/main/jsonschema/test_main_jsonschema.py::test_main_inheritance_forward_ref
CodSpeed Performance Gauge
0%
102.3 ms
102.3 ms
test_main_openapi_nullable_31
tests/main/openapi/test_main_openapi.py::test_main_openapi_nullable_31
CodSpeed Performance Gauge
0%
50.8 ms
50.8 ms
test_main_jsonschema_no_empty_collapsed_external_model
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_no_empty_collapsed_external_model
CodSpeed Performance Gauge
0%
50 ms
50 ms
test_main_jsonschema_nested_deep
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_nested_deep
CodSpeed Performance Gauge
0%
71.2 ms
71.2 ms
test_main_jsonschema_id
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_id
CodSpeed Performance Gauge
0%
54.7 ms
54.7 ms
test_main_openapi_nullable
tests/main/openapi/test_main_openapi.py::test_main_openapi_nullable
CodSpeed Performance Gauge
0%
124.8 ms
124.8 ms
test_main_external_definitions
tests/main/jsonschema/test_main_jsonschema.py::test_main_external_definitions
CodSpeed Performance Gauge
0%
52 ms
52.1 ms
test_main_jsonschema_required_and_any_of_required
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_required_and_any_of_required
CodSpeed Performance Gauge
0%
60.8 ms
60.8 ms
test_main_with_snake_case_field
tests/main/openapi/test_main_openapi.py::test_main_with_snake_case_field
CodSpeed Performance Gauge
0%
114.6 ms
114.6 ms
test_main_nested_directory
tests/main/jsonschema/test_main_jsonschema.py::test_main_nested_directory
CodSpeed Performance Gauge
0%
192.3 ms
192.4 ms
test_main_root_id_jsonschema_self_refs_with_local_file
tests/main/jsonschema/test_main_jsonschema.py::test_main_root_id_jsonschema_self_refs_with_local_file
CodSpeed Performance Gauge
0%
80.6 ms
80.6 ms
test_main_jsonschema_complex_any_of
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_complex_any_of
CodSpeed Performance Gauge
0%
64 ms
64.1 ms
test_main_all_of_ref
tests/main/jsonschema/test_main_jsonschema.py::test_main_all_of_ref
CodSpeed Performance Gauge
0%
53.3 ms
53.3 ms
test_main_jsonschema_multiple_files
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_multiple_files
CodSpeed Performance Gauge
0%
78.9 ms
79 ms
test_main_jsonschema_special_field_name
tests/main/jsonschema/test_main_jsonschema.py::test_main_jsonschema_special_field_name
CodSpeed Performance Gauge
0%
62.9 ms
63 ms
test_main_strict_types_all_with_field_constraints
tests/main/jsonschema/test_main_jsonschema.py::test_main_strict_types_all_with_field_constraints
CodSpeed Performance Gauge
0%
70.2 ms
70.3 ms
test_main_collapse_root_models
tests/main/openapi/test_main_openapi.py::test_main_collapse_root_models
CodSpeed Performance Gauge
0%
77.1 ms
77.2 ms
test_main_openapi_all_of_required
tests/main/openapi/test_main_openapi.py::test_main_openapi_all_of_required
CodSpeed Performance Gauge
0%
54.3 ms
54.4 ms
test_use_default
tests/main/openapi/test_main_openapi.py::test_use_default
CodSpeed Performance Gauge
0%
112.3 ms
112.6 ms

Commits

Click on a commit to change the comparison range
Base
main
d88bc97
-0.01%
dataclass: Add support for const fields using Literal[T] Following up on https://github.com/koxudaxi/datamodel-code-generator/pull/2475 applying the same change to the dataclasses.dataclass writer. That is, represent `"const": <value>` fields as `Literal[<value>]`.
f3200df
6 days ago
by ysndr
© 2025 CodSpeed Technology
Home Terms Privacy Docs