我在设置pylint的地方使用pydev。问题是,即使在评论中,pylint也会报告警告。我希望禁用任何行或块注释中的任何类型的检查。此外,我希望在代码中遵循camelCase命名约定,而不是变量和参数的下划线。有没有办法在不使用pylint插入代码的情况下指定这样的规则:禁用注释?
发布于 2012-04-13 18:14:21
您可以使用以下命令全局禁用某个类的警告
pylint --disable=W1234或使用特殊的PyLint配置文件
pylint --rcfile=/path/to/config.file示例配置文件如下所示:
[MESSAGES CONTROL]
# C0111 Missing docstring
# I0011 Warning locally suppressed using disable-msg
# I0012 Warning locally suppressed using disable-msg
# W0704 Except doesn't do anything Used when an except clause does nothing but "pass" and there is no "else" clause
# W0142 Used * or * magic* Used when a function or method is called using *args or **kwargs to dispatch arguments.
# W0212 Access to a protected member %s of a client class
# W0232 Class has no __init__ method Used when a class has no __init__ method, neither its parent classes.
# W0613 Unused argument %r Used when a function or method argument is not used.
# W0702 No exception's type specified Used when an except clause doesn't specify exceptions type to catch.
# R0201 Method could be a function
# W0614 Unused import XYZ from wildcard import
# R0914 Too many local variables
# R0912 Too many branches
# R0915 Too many statements
# R0913 Too many arguments
# R0904 Too many public methods
disable=C0111,I0011,I0012,W0704,W0142,W0212,W0232,W0613,W0702,R0201,W0614,R0914,R0912,R0915,R0913,R0904,R0801请参阅Pylint's dedicated site上的the documentation。
发布于 2012-04-13 19:58:06
正如pylint --generate-rcfile所说,您可以在~/.pylintrc文件中指定要禁用的消息(请注意,如果您不想使用行内注释,则可以使用pylint --generate-rcfile生成存根文件。
在基本部分的生成文件中,您还会看到"method-rgx“、"function-rgx”等选项,您可以根据自己的喜好进行配置,以支持驼峰样式而不是pep8下划线样式。
发布于 2014-03-13 13:30:31
虽然这是一个老问题,但应该指出的是,现在可以指定他们的own regex for matching with names。
那么匹配camel大小写的正则表达式将如下所示:
[a-z][a-zA-Z0-9]{2,30}$https://stackoverflow.com/questions/10138917
复制相似问题