python - Pylint 与 Django

标签 python python-3.x glob pylint

我在 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/

相关文章:

python - 如何在 Python 中生成唯一随机 float 列表

python-3.x - 拆开 pandas 数据框

glob - 文件路径通配符 (glob) 的 BNF 语法定义

python - Python 中的 Hangman - 辅音猜测编码

python - Django 值错误 : invalid literal for int() with base 10:

python-3.x - 如何将多个单元格添加到bigtable表中的一行?

mongodb - 为什么我不能直接分配 ListField 的值?

node.js - ** 在路径中是什么意思?

android - 如何在 android 中使用 glob 和 sqlite

python - 如何在运行时检查 TypeVar 的类型