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

别等时光非礼了梦想. 提交于 2020-11-30 02:14:07

问题


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.


回答1:


Add your arguments to your USER SETTINGS json file like this:

"python.linting.flake8Args": [
    "--max-line-length=120",
    "--ignore=E402,F841,F401,E302,E305",
],



回答2:


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"
    }



来源:https://stackoverflow.com/questions/50177173/how-do-i-get-flake8-to-reliably-ignore-rules-in-vs-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!