使用pylint的python代码约定 [英] python code convention using pylint

查看:109
本文介绍了使用pylint的python代码约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用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 __ **] || __ 。* __))$)

推荐答案


有些变量名与常量的正则表达式(const-rgx)匹配,而不是与变量名regex(variable-rgx)匹配。

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

这些变量是在模块级别声明?也许这就是为什么将它们视为常量的原因(根据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代码约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆