Flake8 is not a formatter, it's a linter.
It's certainly one of the supported linters of VS Code's Python extension, but it will not affect the setting editor.formatOnSave
or be triggered by the Format Document command. If configured correctly, it should automatically run and check your file for possible issues, then display them on the Problems tab:

If I add:
"python.linting.flake8Args": [
"--ignore=F401"
],
Then the previously displayed F401 error should disappear:

What you seem to be looking for is a formatter. See the Formatting section of the VS Code docs on Python: https://code.visualstudio.com/docs/python/editing#_formatting:
Formatting makes code easier to read by human beings by applying
specific rules and conventions for line spacing, indents, spacing
around operators, and so on (see an example on the autopep8 page).
Formatting doesn't affect the functionality of the code itself.
(Linting, on the other hand, analyzes code for common syntactical,
stylistic, and functional errors as well as unconventional programming
practices that can lead to errors. Although there is a little overlap
between formatting and linting, the two capabilities are
complementary.)
The Python extension supports source code formatting using either
autopep8 (the default), black, or yapf.
Install one of the selected formatters, and enable formatOnSave
:
"[python]": {
"editor.formatOnSave": true
},
"python.formatting.provider": "yapf",
"python.formatting.yapfPath": "/usr/local/bin/yapf",
"python.formatting.yapfArgs": [
"--style=/path/to/setup.cfg"
],
