Last active
August 29, 2015 14:15
-
-
Save kitsuyui/262320e27f47d0b33a83 to your computer and use it in GitHub Desktop.
Python の Lint (文法チェッカ) まとめ - flake8 + hacking を使う - ref: http://qiita.com/kitsuyui/items/5ab4608003a29ff7689f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ autoflake -i --remove-all-unused-imports --remove-unused-variables main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip search flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ autopep8 -i main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main.py:3: local variable 'x' is assigned to but never used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main.py:3: local variable 'x' is assigned to but never used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip install pyformat | |
$ pip install isort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main.py:3:1: H306 imports not in alphabetical order (sys, os) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip install flake8-pep257 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flake8 ⊃ pep8 | |
flake8 ⊃ pyflakes | |
flake8 + flake8-pep257 ⊃ pep257 | |
flake8 + flake8-import-order ⊃ import-order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ flake8 main.py | |
main.py:2:1: F401 'sys' imported but unused | |
main.py:3:1: F401 'os' imported but unused | |
main.py:4:1: E302 expected 2 blank lines, found 0 | |
main.py:5:5: F841 local variable 'x' is assigned to but never used | |
main.py:9:5: E303 too many blank lines (2) | |
main.py:10:14: E271 multiple spaces after keyword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ flake8 main.py | |
main.py:2:1: F401 'sys' imported but unused | |
main.py:3:1: F401 'os' imported but unused | |
main.py:3:1: H306 imports not in alphabetical order (sys, os) | |
main.py:4:1: E302 expected 2 blank lines, found 0 | |
main.py:5:5: F841 local variable 'x' is assigned to but never used | |
main.py:9:5: E303 too many blank lines (2) | |
main.py:10:14: E271 multiple spaces after keyword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip install hacking flake8-import-order flake8-pep257 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ isort -rc main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys # 余分な import | |
import os | |
def fib(): | |
x = 0 # 使ってない変数 | |
a, b = 1, 1 | |
while True: | |
yield a # 余分なスペース | |
a, b = b, a + b | |
if __name__ == '__main__': | |
for i, num in enumerate(fib()): | |
print(num) | |
if i >= 9: | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
def fib(): | |
x = 0 # 使ってない変数 | |
a, b = 1, 1 | |
while True: | |
yield a # 余分なスペース | |
a, b = b, a + b | |
if __name__ == '__main__': | |
for i, num in enumerate(fib()): | |
print(num) | |
if i >= 9: | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pep8 main.py | |
main.py:4:1: E302 expected 2 blank lines, found 0 | |
main.py:9:5: E303 too many blank lines (2) | |
main.py:10:14: E271 multiple spaces after keyword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pyflakes main.py | |
main.py:2: 'sys' imported but unused | |
main.py:3: 'os' imported but unused | |
main.py:5: local variable 'x' is assigned to but never used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ flake8 [対象] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment