我在 Django 项目中有以下目录结构:
.
├── config
├── element
├── home
├── static
├── templates
├── tree
└── user
我正在寻找在所有 python 模块目录上运行 pylint 的最简单命令。
这将是除了“静态”和"template"之外的所有内容。
我测试过例如:
pylint --load-plugins=pylint_django --ignore=static/,templates/ */
但是忽略开关不起作用。
以下当然可以工作:
pylint --load-plugins=pylint_django config element home tree user
但我希望它尽可能动态。当我添加新的 django 应用程序时,我可能会忘记更新 pylint 语句。
编辑: 当我创建以下 .pylintrc 时,
[MASTER]
ignore=templates,static
load-plugins=pylint_django
并运行 pylint --rcfile=.pylintrc */
它给出了这个结果:
************* Module static/__init__.py
static/__init__.py:1:0: F0001: No module named static/__init__.py (fatal)
************* Module templates/__init__.py
templates/__init__.py:1:0: F0001: No module named templates/__init__.py (fatal)
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
第二次编辑: 此行为似乎与“pylint_django”插件一起出现。 I opened an issue therefore.
最佳答案
您可以多次指定--ignore:
pylint --ignore=static --ignore=templates */
或者您可以创建一个 .pylintrc 文件,其中包含以下内容:
[MASTER]
ignore=static,templates
关于python - Pylint 与 Django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58373633/