Pylint 与 Django

Pylint with Django

我在 Django 项目中有以下目录结构:

.
├── config
├── element
├── home
├── static
├── templates
├── tree
└── user

我正在搜索所有 python 模块目录中 运行 pylint 的最简单命令。

这就是除 'static' 和 'templates' 之外的所有内容。

我测试过例如:

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