hhatto / autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide.
https://pypi.org/project/autopep8/
MIT License
4.56k stars 290 forks source link

Max-line-length is ignored, has no effect #497

Open chrisspen opened 5 years ago

chrisspen commented 5 years ago

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.

ForeverRuri commented 5 years ago

same problem. sad.

hhatto commented 5 years ago

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

dansbits commented 4 years ago

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.

LysanderGG commented 4 years ago

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

matkoniecz commented 4 years ago
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?

zensimilia commented 3 years ago

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

matkoniecz commented 3 years ago

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

zensimilia commented 3 years ago

@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

sonologic commented 3 years ago

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$ 
OverLordGoldDragon commented 1 year ago

Same problem with autopep8 2.0.2