39

私はpylintをセットアップしたpydevを使用しています。問題は、コメント内でも pylint が警告を報告することです。行またはブロックコメント内のあらゆる種類のチェックを無効にしようとしていました。また、コード内の変数と引数にアンダースコアの代わりにキャメルケースの命名規則に従いたいと考えています。コードに pylint を挿入せずにそのようなルールを指定する方法はありますか: コメントを無効にしますか?

4

6 に答える 6

51

を使用して、特定のクラスの警告をグローバルに無効にすることができます

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の専用サイトにあるドキュメントを参照してください。

于 2012-04-13T10:14:21.067 に答える
20

cfedermannが述べたように、ファイルで無効にするメッセージを指定できます(インラインコメントを使用したくない場合は、を~/.pylintrc使用してスタブファイルを生成できることに注意してください。pylint --generate-rcfile

生成されたファイルの[BASIC]セクションにも、「method-rgx」、「function-rgx」などのオプションが表示されます。これらのオプションは、pep8アンダースコアスタイルではなくキャメルケーススタイルをサポートするように構成できます。 。

于 2012-04-13T11:58:06.020 に答える