1️⃣ Description
yamllint (1.33.0) output for a file
****.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 ###/
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'
📑 Steps to Reproduce
Build a yml file with wrong indentation: expected at least 1 (indentation)
so that the output from yamllint (1.33.0)
cat test.yml
yamllint test.yml
test.yml
3:1 error wrong indentation: expected at least 1 (indentation)
ℹ️ Environment details
- OS: RedHat 8.8
- Python 3.6.8
- Python 3.11.2
- yamllint 1.33.0
- bash, Version 4.4.20(1)-release
Additional context
HotFix for This Problem
if I change line 256 & 257 in problemfixer.py to
256 if parts[3] == 'at' and isinstance(parts[5], int) :
257 expected = 0
258 found = int(parts[5])
259 elif isinstance(parts[3], int) and isinstance(parts[5], int):
260 expected = int(parts[3])
261 found = int(parts[6])
262 else
263 exit(1)
264 offset = expected - found
it works for this
so that fix_wrong_indentation looks like this
def fix_wrong_indentation(self, left, right):
"""Fix:
- wrong indentation: expected
""" # noqa: D205, D208, D400
# TODO: yamllint only reports the first faulty line in a block :-(
# TODO: see https://github.com/adrienverge/yamllint/issues/427
# TODO: we fix anyway, knowing that we may need to launch the command
# TODO: several times to finally fix the problem.
parts = self.problem.split()
if parts[3] == 'at' and isinstance(int(parts[5]), int):
expected = 0
found = int(parts[5])
elif isinstance(int(parts[3]), int) and isinstance(int(parts[6]), int):
expected = int(parts[3])
found = int(parts[6])
else:
exit(1)
offset = expected - found
if expected > found:
self.ffixer.lines[self.linenum] = (' ' * offset) + left + right
else:
# expected < found because we woudln't be there otherwise anyway
self.ffixer.lines[self.linenum] = (left + right)[-offset:]
self.ffixer.coffset += offset
1️⃣ Description
yamllint (1.33.0) output for a file
****.yml
yamlfixer --nochange --summary --recurse -1 ###/
📑 Steps to Reproduce
Build a yml file with wrong indentation: expected at least 1 (indentation)
so that the output from yamllint (1.33.0)
cat test.yml
yamllint test.yml
ℹ️ Environment details
Additional context
HotFix for This Problem
if I change line 256 & 257 in problemfixer.py to
256 if parts[3] == 'at' and isinstance(parts[5], int) :
257 expected = 0
258 found = int(parts[5])
259 elif isinstance(parts[3], int) and isinstance(parts[5], int):
260 expected = int(parts[3])
261 found = int(parts[6])
262 else
263 exit(1)
264 offset = expected - found
it works for this
so that fix_wrong_indentation looks like this