Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autopep8 not breaking long comment lines?

Tags:

python

pep8

I tried using autopep8 to format some python code, expecting that comment lines above 80 characters would be split up, among other things. I used this test file test.py, which only consists of comments:

#asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
#asdf asdf asdf asdf
#asdf asdf asdf asdf

#asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
#asdf asdf asdf asdf
#asdf asdf asdf asdf
#asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf

I then ran autopep8 test.py

This gives the following output:

# asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
# asdf asdf asdf asdf
# asdf asdf asdf asdf

# asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
# asdf asdf asdf asdf
# asdf asdf asdf asdf
# asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
# asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf

The last long line is split, but the first two aren't. I think all the lines should be broken at 80 characters wide. What am I doing wrong?

like image 740
Douglas B. Staple Avatar asked Jan 29 '14 18:01

Douglas B. Staple


1 Answers

autopep8 doesn't automatically fix all long lines; it only does it in cases where it's deemed 'safe'. See: https://github.com/hhatto/autopep8/issues/39

like image 103
Douglas B. Staple Avatar answered Nov 18 '22 06:11

Douglas B. Staple