[PYTHON] Check the code with flake8

My name is Kazuhiro Minomaki (https://qiita.com/mimaki_kazuhiro) and I am an intern at Future Electronic Technology. This time I will write about flake8.

Since you are a beginner in programming, the content may be incorrect. If there are any mistakes, I will correct them so please point out more and more.

What is flake8

flake8 is a Python grammar check tool.

Introduction of flake8

I will actually use it. First install.

terminal


$ pip install flake8

If you execute flake8 with the file name specified as shown below, the result of the code check will be displayed. The command argument can be a directory name instead of a file name.

terminal


$ flake8 test.py
test.py:1:1: F401 'sys' imported but unused
test.py:3:4: E222 multiple spaces after operator
test.py:4:7: E231 missing whitespace after ','
test.py:4:12: E202 whitespace before ']'
test.py:6:1: W293 blank line contains whitespace
test.py:6:1: W391 blank line at end of file

In this way, mistakes can be detected.

Recommended Posts

Check the code with flake8
Decrypt the QR code with CNN
Mechanism for automatic lint check with flake8 when committing python code
Check the HTTP status code response with the curl command (#Linux #Shell)
Check the correlation with Kaggle's Titanic (kaggle③)
Check the memory protection of linux kerne with the code for ARM
Check the file size with du -sh *
Check the date of the flag duty with Python
Convert the character code of the file with Python3
Strengthen with code test ⑦
Strengthen with code test ⑨
Strengthen with code test ③
Strengthen with code test ⑤
Strengthen with code test ④
Strengthen with code test ②
Domain check with Python
Hamming code with numpy
Strengthen with code test ①
Check version with python
Strengthen with code test ⑧
Strengthen with code test ⑨
Check when the version does not switch with pyenv
Get country code with python
Python with VS Code (Windows 10)
I wrote the code for Japanese sentence generation with DeZero
Test code to check for broken links in the page
Check what line caused the error with apply () (dataframe, Pandas)
Insert the debugger with nose
Check python coverage with pytest-cov
Kill the process with sudo kill -9
Check the memory status of the server with the Linux free command
Tool to check code style
Explain the code of Tensorflow_in_ROS
Enjoy the Gray-Scott model with short code using matrix math
Source code character code check script
Check the operating status of the server with the Linux top command
Debug Python with VS Code
Guess the password with klee
The story that Python stopped working with VS Code (Windows 10)
scraping the Nikkei 225 with playwright-python
Calibrate the model with PyCaret
Call the API with python3.
System trade starting with Python3: Get the latest program code
[Python] Check the installed libraries
Document Python code with Doxygen
[Machine learning] Check the performance of the classifier with handwritten character data
Check server I / O device usage with the Linux iostat command
I want to check the position of my face with OpenCV!
Extract the xz file with python
Java with Visual Studio Code (Part 2)
Check the behavior when assigning Python
Extract the maximum value with pandas.
Classify "Wine" with TensorFlow MLP code
Check the return value using PEP 380
Use the preview feature with aws-cli
Specifying the date with the Twitter API
The universe is dangerous with PyEphem
Pave the road with combinatorial optimization
Run the app with Flask + Heroku
Get the weather with Python requests
Get the weather with Python requests 2