2012-04-13 18 views
29

私はpylintをセットアップした場所でpydevを使用しています。 問題は、コメントの中でさえ、pylintが警告を報告するということです。どのような行やブロックコメントでもチェックを無効にすることを考えていました。 また、コード内の変数や引数の下線の代わりにcamelCaseの命名規則に従いたいと考えています。 pylintでコードを挿入せずにこのようなルールを指定する方法はありますか?コメントを無効にしますか?Pylintのエラーチェックはカスタマイズできますか?

+2

キャメルケースを使用しないでください。 –

+4

あなたのコメントは正当なものですが、私は主にJava開発者のチームであり、保守性/受諾性を高めるために、私はPythonコードから逸脱しなければなりませんでした。 –

+0

場合によっては、ラクダの場合が正当である。たとえば、PySideまたはPyQtを使用する場合。 Qt-ishのラクダのケースとPythonのアンダースコアスタイルを混在させるのは恐ろしいことです。 –

答えて

38

あなたはグローバル

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 

を参照してください。http://www.logilab.org/4736

Pylintには現在専用サイトがあります:http://www.pylint.org/と更新されたドキュメント:http://docs.pylint.org/

+0

良い答えですが、それ以上はあります。複数のプロジェクトやより複雑なシナリオで細かい粒度制御が必要な場合は、私の答えを参照してください。 http://stackoverflow.com/a/32672068/763269 –

+1

端末で 'pylint --disable = C0111'を試して、' Usage:pylint [options] module_or_package'を取得しました。私は何か見落としてますか? –

18

〜/ .pylintrcファイルで無効にするメッセージを指定できます(インラインコメントを使用しない場合は "pylint --generate-rcfile"を使用してスタブファイルを生成できます)。

生成されたファイルの[BASIC]セクションには、「method-rgx」、「function-rgx」などのオプションも表示されます。これらのオプションは、ラクダのケーススタイルpep8は、スタイルを強調するのではなく。

3

これは古い質問ですが、1が今自分own regex for matching with namesを指定することができます言及する必要があります。

キャメルケースにマッチするあなたの正規表現は、次のようなものになります。

[a-z][a-zA-Z0-9]{2,30}$ 
関連する問題