visual-studio-codeflake8

FileNotFoundError for flake8 python linter args in VSCode


A FileNotFoundError is shown when I use the new Python linting interface in VSCode. I install the new flake8 extension, go to settings and add a flake8 config such as:

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

This results in a linting error such as

FileNotFoundError: [Errno 2] No such file or directory: 'max-line-length = 120'

In addition the flake8 settings are not applied (default max line length of 80 is set).


Solution

  • This issue happens when the args set for flake8 have incorrect syntax. In this case I am missing the initial double hyphen and I have spaces around the equals sign. The following solves the issue and results in correct setting of flake8 args.

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