google / yamlfmt

An extensible command line tool or library to format yaml files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request: `indent` being respected beyond top level

jamesbraza opened this issue · comments

The below:

repos:
    - repo: https://github.com/pre-commit/pre-commit-hooks
      rev: v4.4.0
      hooks:
          - id: check-byte-order-marker
          - id: check-docstring-first
          - id: requirements-txt-fixer
            description: >-
                Sorts entries in requirements.txt and removes incorrect entry
                for `pkg-resources==0.0.0`.

With -formatter=indent=4,scan_folded_as_literal=true being passed to yamlfmt gets corrected to:

repos:
    - repo: https://github.com/pre-commit/pre-commit-hooks
      rev: v4.4.0
      hooks:
        - id: check-byte-order-marker
        - id: check-docstring-first
        - id: requirements-txt-fixer
          description: >-
            Sorts entries in requirements.txt and removes incorrect entry
            for `pkg-resources==0.0.0`.

We can see the top level 4-space indent was preserved, but not the nested levels beyond that.

Can we make indent be recursive?

The bug appears to be specifically with nested arrays. I will try and find time to fix it.