Skip to content

Formatting

Code generated by datamodel-codegen will be passed through isort and black to produce consistent, well-formatted results. Settings for these tools can be specified in pyproject.toml (located in the output directory, or in some parent of the output directory). Also for black you can disable skip-string-normalization with using datamodel-codegen option --use-double-quotes, it will override your black config skip-string-normalization value. Using --use-double-quotes may be useful if you can't use black config.

Example pyproject.toml:

[tool.black]
skip-string-normalization = true
line-length = 100

[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 100
known_first_party = "kelvin"

See the Black Project for more information.