Search code examples
pythonvisual-studio-codeautopep8

Autopep8 format "max-line-length" parameter is not working for the imports section


I'm using autopep8 auto-formatter in VSCode (MacOs) but I can't seem to make it work to split lines greater than max-line-length in the imports section. In the rest of the code file, it works well, but not in the imports section. These are my configurations in settings.json:

"python.languageServer": "Pylance",
"python.formatting.autopep8Args": [
"--max-line-length",
"80",
],
"python.formatting.provider": "autopep8",
"python.linting.pylintEnabled": true,
"python.linting.flake8Enabled": false,
"python.linting.enabled": true,

Any idea why?


Solution

  • That way of adding autopep8 args is deprecated. It shows up greyed out in your settings.json. Instead add this:

    "autopep8.args": [
        "--max-line-length=120"
    ],