pydantic-yaml
pydantic-yaml copied to clipboard
Is there a mechanism or pattern for Block Style Literal Strings
I have a string content that is muliline and currently I can use pydantic-yaml with ruamel to dump it as yaml. It uses the quoted string format.
Is there an option to use the block style ?
Or can suggest some options to consider.
https://yaml-multiline.info
Hi, improving the flexibility of dumping YAML is something that's been on my wanted list for a while. It might wait until Pydantic 2.0 releases and I'll need to totally rewrite this... I'll probably base it around ruamel's or even (shudders) do the YAML part myself.
Hi @Bengreen, in terms of user experience - would you prefer to do this configuration within the model class itself (using Pydantic-like config class) or within the "dumping engine" as a global configuration? How did you use it in the case above?
Currently, limited support for this is now available within to_yaml_str and to_yaml_file using dumping keywords (since 1.1.0), or with a custom YAML dumper instance. For example, you could try configuring text longer than some length to use a block style. You'll have to go through the internals of ruamel.yaml though.