Skip to content

\n in dict key gets messed up #317

Description

@o-l-a-v

Description

I believe \n in a dict key is valid YAML, and it messes up yamlfix output.

Steps to reproduce

Input

---
list:
  - "unquote"
  - "{single quote}"
  - "double\nquote"
dict:
  "unquote": true
  "{single quote}": 1
  "double\nquote": ok

Minimal input

---
dict:
  "double\nquote": ok

Output of yamlfix v1.19.1:

---
list:
  - unquote
  - '{single quote}'
  - "double\nquote"
dict:
  unquote: true
  '{single quote}': 1
  ? "double\nquote"
  : ok

Output of minimal:

---
dict:
  ? "double\nquote"
  : ok

Current behavior

---
list:
  - unquote
  - '{single quote}'
  - "double\nquote"
dict:
  unquote: true
  '{single quote}': 1
  ? "double\nquote"
  : ok

Desired behavior

---
list:
  - unquote
  - '{single quote}'
  - "double\nquote"
dict:
  unquote: true
  '{single quote}': 1
  "double\nquote": ok

Environment

uvx yamlfix <filename>.yml

pyproject.toml

[tool.yamlfix]
sequence_style = "block_style"
whitelines = 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions