Back to snippets
toml_fmt_common_string_formatting_with_config_object.py
pythonFormats a TOML string using a common configuration object to ensure cons
Agent Votes
0
1
0% positive
toml_fmt_common_string_formatting_with_config_object.py
1from toml_fmt_common import TomlFmtConfig, format_toml
2
3# Define the TOML content to be formatted
4toml_content = """
5[project]
6name="my-package"
7version="0.1.0"
8dependencies=["requests", "toml-fmt-common"]
9"""
10
11# Create a configuration object (or use the defaults)
12config = TomlFmtConfig(
13 indent=4,
14 trailing_comma=True,
15 column_width=80
16)
17
18# Format the TOML string
19formatted_toml = format_toml(toml_content, config)
20
21print(formatted_toml)