Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
31
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

Pylintの使い方メモ

インストールと準備

pip install pylint
pylint --generate-rcfile > ~/.pylintrc

~/.pylintrcを修正してカスタマイズすることができる

例えば

const-rgx=[a-z_][a-z0-9_]{2,30}$
const-name-hint=[a-z_][a-z0-9_]{2,30}$
include-ids=yes
symbols=yes
disable=W0142,C0111

を指定、W0142は **kwargs などの引数のワーニングを出さないようにする設定。
disableの設定をいじって何をチェックするかなど調整することができる。
PyLint メッセージ一覧

出力のフォーマットについて

メッセージタイプ: 行:[オブジェクト:] メッセージ

  • 主なメッセージタイプ説明
    • (C) convention, コーディング基準まもってなくねぇか?
    • (R) refactor, リファクタリングが必要じゃない?
    • (W) warning, Python特有の問題かも?
    • (E) error, バグがあるかもよ?

使い方例

$ pylint somefile.py

Warning: option include-ids is deprecated and ignored.
Warning: option symbols is deprecated and ignored.
************* Module handlers.account
W: 15, 4: Arguments number differs from overridden method (arguments-differ)
W: 22, 8: Attribute 'ERRORS' defined outside __init__ (attribute-defined-outside-init)
W: 85, 8: No exception type(s) specified (bare-except)
E: 66,19: Class 'User' has no 'objects' member (no-member)
E:100, 8: Bad first argument 'CommonHandler' given to super() (bad-super-call)
E:112,19: Class 'User' has no 'objects' member (no-member)
E:136, 8: Bad first argument 'CommonHandler' given to super() (bad-super-call)
W:160, 8: No exception type(s) specified (bare-except)
E:146,23: Class 'User' has no 'objects' member (no-member)
E:148,19: Class 'User' has no 'DoesNotExist' member (no-member)
E:172, 8: Bad first argument 'CommonHandler' given to super() (bad-super-call)

...

Global evaluation
-----------------
Your code has been rated at 6.90/10 (previous run: 6.43/10, +0.48)

...

みたいな感じで、評価が出る。
前回との差も出してくれるみたい。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
31
Help us understand the problem. What are the problem?