Line wrapping exeeds requested width with for quioted and folded strings
ruamel.yaml is a YAML 1.2 parser/emitter for Python
Brought to you by:
anthon
Line wrapping works correctly for unquoted strings but doesn't for quoted and folded ones. This causes issues with formatters/linters which are based on ruamel.yaml (e.g. ansible-lint --fix).
# Unquoted: OK (max: 80)
echo "key: $(seq -s " " 1 150)" | uv run python3 -c "import sys; from ruamel.yaml import YAML; yaml = YAML(); yaml.preserve_quotes = True; yaml.dump(yaml.load(sys.stdin), sys.stdout)" | wc -L
# OUTPUT: 80
# Quoted: Wrong (max: 83)
echo "key: \"$(seq -s " " 1 150)\"" | uv run python3 -c "import sys; from ruamel.yaml import YAML; yaml = YAML(); yaml.preserve_quotes = True; yaml.dump(yaml.load(sys.stdin), sys.stdout)" | wc -L
# OUTPUT: 83
# Folded: Wrong (max: 82)
echo -e "key: >\n $(seq -s " " 1 150)" | uv run python3 -c "import sys; from ruamel.yaml import YAML; yaml = YAML(); yaml.preserve_quotes = True; yaml.dump(yaml.load(sys.stdin), sys.stdout)" | wc -L
# OUTPUT: 82
Could somebody change the title and replace "exeeds" with "exceeds", "quioted" by "quoted"? It seems I can't.
Last edit: Stanislav German-Evtushenko 2026-01-28
I've created another one with a proper title, feel free to close this one.