You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
When a ran autopep8 over a large codebase, I noticed one file that was causing it to crash.
It seems to only happen in specific cases. This is what I had to have in my Python file in to get it to trigger:
A function
A single empty line
A long comment (long enough to trigger E501, 80 characters in my case)
A variable assignment
Example code:
deffoo(bar):
pass#This is a long comment. It has more than 80 characters in it. It triggers an E501baz= []
Which gives the following stack trace:
$> env/bin/autopep8 test.py
Traceback (most recent call last):
File "env/bin/autopep8", line 11, in <module>
sys.exit(main())
File "env/lib/python2.7/site-packages/autopep8.py", line 3811, in main
fix_multiple_files(args.files, args, sys.stdout)
File "env/lib/python2.7/site-packages/autopep8.py", line 3723, in fix_multiple_files
_fix_file((name, options, output))
File "env/lib/python2.7/site-packages/autopep8.py", line 3704, in _fix_file
fix_file(*parameters)
File "env/lib/python2.7/site-packages/autopep8.py", line 3104, in fix_file
fixed_source = fix_lines(fixed_source, options, filename=filename)
File "env/lib/python2.7/site-packages/autopep8.py", line 3084, in fix_lines
fixed_source = fix.fix()
File "env/lib/python2.7/site-packages/autopep8.py", line 564, in fix
aggressive=self.options.aggressive))
File "env/lib/python2.7/site-packages/autopep8.py", line 507, in _fix_source
modified_lines = fix(result)
File "env/lib/python2.7/site-packages/autopep8.py", line 872, in fix_long_line_physically
original=target)
File "env/lib/python2.7/site-packages/autopep8.py", line 903, in fix_long_line
verbose=self.options.verbose)
File "env/lib/python2.7/site-packages/autopep8.py", line 1166, in get_fixed_long_line
key=lambda x: line_shortening_rank(
File "env/lib/python2.7/site-packages/autopep8.py", line 1170, in <lambda>
experimental=experimental))
File "env/lib/python2.7/site-packages/autopep8.py", line 3465, in line_shortening_rank
lines[0].rstrip()[-1] not in '([{'
IndexError: string index out of range
Adding the --ignore=E501 flag makes it work again.
Tested with:
cPython 2.7.5 (on CentOS 7) and cPython 2.7.13 (on Windows 10)
autopep8 1.3.2 (pycodestyle: 2.3.1)
The text was updated successfully, but these errors were encountered:
When a ran autopep8 over a large codebase, I noticed one file that was causing it to crash.
It seems to only happen in specific cases. This is what I had to have in my Python file in to get it to trigger:
Example code:
Which gives the following stack trace:
Adding the
--ignore=E501
flag makes it work again.Tested with:
The text was updated successfully, but these errors were encountered: