andreoliwa / nitpick

Enforce the same settings on multiple projects
https://nitpick.readthedocs.io/
MIT License
393 stars 24 forks source link

`nitpick` removes YAML document start #621

Open jamesbraza opened 10 months ago

jamesbraza commented 10 months ago

Expected behavior

I run yamllint --strict (docs), which checks for the presence of a YAML document start.

I am finding nitpick making extra diff churn because pre-commit configs don't use document start.

Current behavior

When running nitpick, it removes the document start.

Steps to reproduce

  1. Have a .pre-commit-config.yaml that previously has a document start ---
  2. Run nitpick fix to generate an updated .pre-commit-config.yaml
  3. Observe it removed document start ---

Possible Solution

Adding a CLI flag for preserving document starts in YAML somehow.

Context

N/a

Your environment

andreoliwa commented 10 months ago

Hi, thanks for the multiple bug reports. :)

Adding a CLI flag for preserving document starts in YAML somehow.

I would say Nitpick should preserve existing content whenever possible, without any CLI flags.

I didn't check ruamel.yaml's docs yet; it's the YAML-preserving package I use. I don't remember configuring it to remove document starts, I'm not sure if it is configurable at all. I'll check it when working on this bug. 👍🏻