enabling pylint_django plugin in vscode, pylint stop working

ぃ、小莉子 提交于 2021-01-20 23:40:25

问题


That's my user settings in vscode

{
  "python.pythonPath": "/Users/cristiano/miniconda3/envs/django-rest-2/bin/python",
  "python.linting.pylintEnabled": true,
  "python.linting.enabled": true,
  "python.linting.pylintArgs": [
    "--load-plugins",
    "pylint_django"
  ],
}

I installed the plugin via conda, same as the pylint

pylint                    2.1.1                    py36_0
pylint-django             0.11.1                     py_1    conda-forge
pylint-plugin-utils       0.4                        py_0    conda-forge

If i commented out the "python.linting.pylintArgs" section, pylint works with no problem. I ned to enable the plugin to avoid django-specific errros such as "Entity.objects.all()", but if I enable it, the lint stop working: it does not highlight standard errors o warning the previously was doing it.

I have same exact behaviour using vscode for win and mac. I tried also to use the .pylintrc file as described here but I have the same result: lint stop working. Same behaviour using base conda env or a custom one.


回答1:


This config for pylint is working for me:

"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
    "--disable=C0111", // missing docstring
    "--load-plugins=pylint_django,pylint_celery",
 ],



回答2:


I just got the same issue. Like @J0hnG4lt said, I had a problem with the python path. I didn't point to the path of the environment, which I have installed pylint_django. This config is work for me. Thanks @Manu.

"python.pythonPath": "/Users/mc976/Documents/Programming/Python/Practice/music_service/venv/bin/python3",
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
    "--disable=C0111",
    "--load-plugins",
    "pylint_django"
]

Besides, I think you should check your environment to make sure that you have correctly installed pylint_django by using pip list.




回答3:


My issue was more prosaic (but perhaps it will help other forehead slappers like myself). Run the PIP install in the correct virtualenv directory!

pip install pylint-django --upgrade

Also note that plugin errors cause Pylint to completely fail to load silently. Start with blank pylintArgs and slowly add them back one at a time to see where things go awry.




回答4:


found a working answer for myself here: https://donjayamanne.github.io/pythonVSCodeDocs/docs/linting/

my settings.json file now reads:

{
    "python.pythonPath": "C:\\ProgramData\\Anaconda3\\envs\\djangoSite2\\python.exe",
    "python.linting.pylintEnabled": true,
    "python.linting.pylintArgs": ["--disable=C0111","--load-plugins", "pylint_django"],
}

this then adds linting, but doesn't throw an error on fields that it can't find (like the Entity.objects.all() one), but has the disadvantage that if you then try and reference something that really doesn't exist it doesn't throw an error.




回答5:


It now works on my Mac. This is my workspace's settings.json:

{
"python.linting.pylintEnabled": true,
"python.linting.pycodestyleEnabled": false,
"files.autoSave": "afterDelay",
"editor.fontSize": 14,
"editor.wordWrapColumn": 90,
"editor.autoClosingQuotes": "beforeWhitespace",
"python.pythonPath": "/Users/myname/anaconda3/envs/myproject/bin/python",
"python.linting.pylintArgs": [
    "--disable=C0111", // missing docstring
    "--load-plugins=pylint_django",
 ],

}

I had to be careful to have installed pylint-django into the correct python environment. For me, this meant running this command in the terminal:

$ /Users/myname/anaconda3/envs/myproject/bin/python -m install pip pylint pylint-django



来源:https://stackoverflow.com/questions/53304116/enabling-pylint-django-plugin-in-vscode-pylint-stop-working

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