问题描述
我正在尝试使用pylint来检查源代码中的约定。某些变量名与常量的正则表达式( const-rgx
)匹配,而不是变量名regex( variable-rgx
)。如何将变量名与 variable-rgx
匹配?还是应该用 variable-rgx
的东西扩展 const-rgx
?
I'm trying out pylint to check my source code for conventions. Somehow some variable names are matched with the regex for constants (const-rgx
) instead of the variable name regex (variable-rgx
). How to match the variable name with variable-rgx
? Or should I extend const-rgx
with my variable-rgx
stuff?
eg
C0103:31:无效的名称设置(应匹配(([[A-Z _] [A-Z1-9 __ **] || __ 。* __))$)
推荐答案
这些变量是在模块级别声明?也许这就是为什么将它们视为常量的原因(根据PEP-8,至少应该这样声明它们)。
Are those variables declared on module level? Maybe that's why they are treated as constants (at least that's how they should be declared, according to PEP-8).
这篇关于使用pylint的python代码约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!