개발/Python

python code style check (pycodestyle)

강서버 2021. 5. 31. 12:20
728x90
반응형

1. pycodestyle install (Windows / Ubuntu)

pip install pycodestyle

 

2. code style check

Error / Warning code

- Error code : Exxx / ex) E226

- Warning code : Wxxx / ex) W391

* detail code description  : https://pep8.readthedocs.io

 

pep8’s documentation — pep8 1.7.1 documentation

Docs » pep8’s documentation Edit on GitHub Credits Created by Johann C. Rocholl. Maintained by Florent Xicluna and Ian Lee. License The pep8 library is provided under the terms and conditions of the Expat license: # Permission is hereby granted, free of

pep8.readthedocs.io

(E2 : 공백 문제, E3 : 빈 줄 문제, W3 : 빈 줄 문제, W6 : 더는 사용되지 않는 기능)

 

2.1 Windows - Command(cmd.exe)

[ Error / Warning ]

> pycodestyle test.py

test.py:18:11: E226 missing whitespace around arithmetic operator

 

> echo %ERRORLEVEL%

1

 

* ignore code

> pycodestyle --ignore=E2 test.py

 

[ Success ]

> pycodestyle test.py

 

 

> echo %ERRORLEVEL%

0

 

2.2 Ubuntu - Terminal

[ Error / Warning ]

$ pycodestyle test.py

test.py:21:1: W391 blank line at end of file

 

$ echo $?

1

 

* ignore code

$ pycodestyle --ignore=W3 test.py

 

[ Success ]

$ pycodestyle test.py

 

 

$ echo $?

0



참고 : [도서] 진지한 파이썬

 

728x90
반응형