使用pylint的python代码约定

标签 python conventions pylint

我正在尝试使用 pylint 检查我的源代码的约定。不知何故,一些变量名与常量的正则表达式 (const-rgx) 而不是变量名正则表达式 (variable-rgx) 匹配。 variable-rgx如何匹配变量名?或者我应该用我的 variable-rgx 东西扩展 const-rgx 吗?

例如
C0103: 31: 名称“设置”无效(应匹配 (([A-Z_][A-Z1-9_]*)|(__.*__))$)

最佳答案

Somehow some variable names are matched with the regex for constants (const-rgx) instead of the variable name regex (variable-rgx).

这些变量是在模块级别声明的吗?也许这就是它们被视为常量的原因(根据 PEP-8,至少应该这样声明它们)。

关于使用pylint的python代码约定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/709490/

相关文章:

asp.net-mvc - Durandal 和 ASP.NET MVC 约定

python - 使用列名 reshape 长到宽

python - 一种保证从无序字典中排序键/值列表的方法?

python - 检查自定义 __getitem__ 方法的 "key"参数是否为切片的 pythonic/更快方法是什么?

javascript - 覆盖 Javascript 函数的参数对象

node.js - Node : should package. json 位于 src 文件夹中还是位于父文件夹中?

python - Pylint 在以正确的顺序导入时提示

python - Pylint raise-missing-from

python-3.x - pylint 误报 E0401 在使用 venv 时在 vscode 中导入错误

python - Numpy View Reshape Without Copy(二维移动/滑动窗口、步幅、屏蔽内存结构)