autopep8 icon indicating copy to clipboard operation
autopep8 copied to clipboard

Max-line-length is ignored, has no effect

Open chrisspen opened this issue 5 years ago • 10 comments

The docs for E501 specify "Try to make lines fit within --max-line-length characters."

Therefore, if I wanted to use autopep8 to only reformat line length, I would presumably run:

autopep8 --max-line-length <length> --in-place --recursive --select=E501 somefile.py

However, I'm finding this command has no effect. On a file with code in excess of 100 columns, running:

autopep8 --max-line-length 80 --in-place --recursive --select=E501 somefile.py

does not modify the file in any way, when I would expect it to reformat code into continuations and wrap docstrings and comments.

I'm running autopep8 1.4.4 with Python 3.7.3.

chrisspen avatar Aug 12 '19 20:08 chrisspen

same problem. sad.

ForeverRuri avatar Aug 15 '19 08:08 ForeverRuri

It has no effect unless you give any of the -a, -aa, -aaa options.

hhatto avatar Sep 12 '19 13:09 hhatto

I'm also seeing no effect, even with the any number of -a options. Even if I try running this on the sample code in the readme, line length is not being corrected.

dansbits avatar Oct 28 '19 13:10 dansbits

1.4.3 seems fine with -a, 1.4.4 seems to not handle line length at all

LysanderGG avatar Nov 19 '19 04:11 LysanderGG

autopep8 1.5.4 (pycodestyle: 2.6.0)

splits lines with autopep8 --in-place address_imported_cities.py -a --jobs 0 and autopep8 --in-place address_imported_cities.py -aa --jobs 0 commands.

Both are not working as I would expect (I will file issue if PEP8 agrees with me), but there is some effect.

@chrisspen Can you present code that is not processed properly?

matkoniecz avatar Aug 17 '20 13:08 matkoniecz

2 april 2021: autopep8-1.5.6 pycodestyle-2.7.0 still not working with --max-line-length.

zensimilia avatar Apr 02 '21 09:04 zensimilia

@zensimilia Can you give example of code not working as expected?

matkoniecz avatar Apr 02 '21 09:04 matkoniecz

@matkoniecz this one:

from app.module.long.name import function_one, function_two, function_with_long_name, function_for_test


def my_super_test_function(argument: str, test_passed: bool, so_long_string_for_test_purposes: str):
    print('hello world')

command: autopep8 --max-line-length 80 --diff test.py

zensimilia avatar Apr 02 '21 13:04 zensimilia

Here's another one:

(env) gmc@sunra:~/tmp$ autopep8 --version
autopep8 1.5.7 (pycodestyle: 2.7.0)
(env) gmc@sunra:~/tmp$ cat test.py
def foo():
    print("way                      too                                long                         string                should            be   split")

(env) gmc@sunra:~/tmp$ autopep8 test.py 
def foo():
    print("way                      too                                long                         string                should            be   split")
(env) gmc@sunra:~/tmp$ autopep8 -a test.py 
def foo():
    print("way                      too                                long                         string                should            be   split")
(env) gmc@sunra:~/tmp$ autopep8 -aa test.py 
def foo():
    print("way                      too                                long                         string                should            be   split")
(env) gmc@sunra:~/tmp$ autopep8 -aaa test.py 
def foo():
    print("way                      too                                long                         string                should            be   split")
(env) gmc@sunra:~/tmp$ autopep8 -aaa --experimental test.py 
def foo():
    print("way                      too                                long                         string                should            be   split")
(env) gmc@sunra:~/tmp$ 

sonologic avatar Jul 13 '21 13:07 sonologic

Same problem with autopep8 2.0.2

OverLordGoldDragon avatar Aug 05 '23 22:08 OverLordGoldDragon