adrienverge / yamllint

A linter for YAML files.
GNU General Public License v3.0
2.79k stars 265 forks source link

problemfixer.py", line 256, in fix_wrong_indentation #640

Closed af-now-it closed 6 months ago

af-now-it commented 6 months ago

yamllint output for a file host_vars/****.yml

  1:1       warning  missing document start "---"  (document-start)
  2:1       error    wrong indentation: expected _at least 1_  (indentation)
  10:3      error    wrong indentation: expected 4 but found 2  (indentation)

$ yamlfixer --nochange --summary --recurse -1 host_vars/

Traceback (most recent call last):
  File "/###/.local/bin/yamlfixer", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/###/.local/lib/python3.11/site-packages/yamlfixer/__main__.py", line 151, in run
    return yfixer.fix()
           ^^^^^^^^^^^^
  File "/###/.local/lib/python3.11/site-packages/yamlfixer/yamlfixer.py", line 167, in fix
    (status, unidiff) = filetofix.fix()
                        ^^^^^^^^^^^^^^^
  File "/###/.local/lib/python3.11/site-packages/yamlfixer/filefixer.py", line 211, in fix
    handled = ProblemFixer(self, linenumber, colnumber, problem)()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/###/.local/lib/python3.11/site-packages/yamlfixer/problemfixer.py", line 55, in __call__
    getattr(self, methodname)(left, right)
  File "###/.local/lib/python3.11/site-packages/yamlfixer/problemfixer.py", line 256, in fix_wrong_indentation
    expected = int(parts[3])

            ^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'at'

change to

256         if parts[3] == 'at':
257             expected = 0
258             found = int(parts[5])
259         else:
260             expected = int(parts[3])
261             found = int(parts[6])
262         offset = expected - found
adrienverge commented 6 months ago

It looks like a yamlfixer issue, please report it on yamlfixer issue tracker.

af-now-it commented 6 months ago

yes i yous a link in the source of yamlfixer sorry