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.
To disable TypeScript warnings in VS Code, we can set a few options in our VS Code settings to disable them. { //... "typescript. validate. enable": false, "javascript.
To disable TSLint in VS Code, we can set the "typescript. validate. enable" setting to false in our VS Code settings. json file.
Add your arguments to your USER SETTINGS json file like this:
"python.linting.flake8Args": [
"--max-line-length=120",
"--ignore=E402,F841,F401,E302,E305",
],
note that flake8 uses
"python.linting.flake8Args": [
whereas black seems to use:
"python.formatting.blackArgs": [
if you're using both (or toggling) these settings maybe helpful:
{
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--line-length",
"120"
],
"python.linting.flake8Args": [
"--max-line-length=120",
"--ignore=E402",
],
"python.pythonPath": "venv/bin/python"
}
I ran into this problem recently. I ran into problems because I was setting the argument to --config flake8.cfg
instead of --config=flake8.cfg
. Under the hood, vscode puts the CLI argument in quotes. Adding "--config flake8.cfg"
to the flake8 command seems to confuse flake8 into thinking that it's looking at a file path and not a CLI argument.
The solution for me was to either set the args as --config=flake8.cfg
(with the equals sign) or the args up into separate items in the array:
"python.linting.flake8Args": [
"--config",
"flake8.cfg"
]
The solution proposed by reka18 is great and was no doubt written specifically for the original question.
From a more general stand point, I would advise against using this kind of trick if you work on a project that has dedicated configuration files.
You are guaranteed to run into incomprehensible configuration conflicts and will possibly ignore rules that were purposefully enforced by the project.
In this case, you should use the following instead:
assuming the file is named .flake8 and is present at the project's root folder
// .vscode/settings.json
"python.linting.flake8Args": ["--config", ".flake8"],
Using --config .flake8
ensures only this file will be read (See official doc).
So it is important to use this option, even though it is a default value. Otherwise, a custom user configuration in a parent folder could accidentally be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With