You do not have 32 lines in your file (perhaps because you deleted the non-essential data from the example), but the indent level points to the line with fi .
In fact, the problem starts earlier, and what you want to do is specify the action that will be executed as a multi-line string. You can specify them in YAML in several ways, but the purest is to use a literal scalar indicator | "which stores newline characters:
install: - | if [[ "${TEST_PY3}" == "false" ]]; then pip install Cython; python setup.py build;
For these errors, there is no automatic YAML resubmission tool.
Reindenters for Python accepts working code and indentes permanently (replacing TAB, always the same indentation per level). Repeatedly subtracting code from code to code with syntax errors either does not work, or may lead to incorrect results.
The reenders for YAML face the same problem: what to do if the input does not make sense (and what is clear to you and to me is not always clear to the program). Just doing everything that is not parsed in a multi-line scalar is not a general solution.
In addition, most YAML analysts throw out some information about reading in files that you wonβt want to get lost when re-indenting, including EOL comments, manually created anchor names, key bindings, etc. All without violating the requirements in the specification.
If you want to consistently depart from your (correct) YAML, you can use the yaml utility, which is part of the package [ruamel.yaml][2] (disclaimer: I am the author of this package). Your original input used with yaml round-trip .travis.yml will give:
... in "<byte string>", line 3, column 3: - if [[ "${TEST_PY3}" == "false" ... ^ expected <block end>, but found '<scalar>' in "<byte string>", line 6, column 7: mkdir core;
Unfortunately, it is not much more useful to find an error, the correct version of .travis.yml passing through yaml round-trip .travis.yml will tell you that it stabilizes in the second round (i.e., it gets lost in the first extra space). And yaml round-trip .travis.yml --save gives you:
install: - | if [[ "${TEST_PY3}" == "false" ]]; then pip install Cython; python setup.py build;
Note that there is no YAML comment in this # TO build networkx-metis . This is just part of a multi-line string. However, the comment on the line before the first or after the last will remain.