visual-studio-codeflake8

How do I get flake8 to reliably ignore rules in VS Code?


Two things that annoy me. First is the warning Flake8 gives me when I type more than 80 characters on a line. Second is the warnings I get when I haven't yet used a module name that I imported. I've looked at all the documentation on using Flake8 in the terminal. No use.

flake8 --ignore=E402
flake8 --max-line-length=120

This doesn't work. At least VS Code doesn't show any effect.


Solution

  • In my case (vscode 1.72.2, flake 5.0.4) it only worked by adding:

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

    in the settings.json

    I prefer editing the Workspace settings, namely <root project folder>/.vscode/settings.json, because I store it in version control. This way it is backed up and everyone working on the project will get it.

    What was suggested in most of the other answers:

    "python.linting.flake8Args": [
       "--max-line-length=120",
    ],
    

    had no effect for me.