-
-
Notifications
You must be signed in to change notification settings - Fork 3
Guide to install flake8
Daniel-Runge edited this page Sep 29, 2022
·
3 revisions
#How to install and use Flake8?
You can install flake8 and its extensions with pip or pipx:
$ pip install flake8
# Or even better
$ pipx install flake8
# Install extensions
# These commands install formatters for imports and docstrings
$ pip install flake8-docstrings flake8-isort
# Or
$ pipx inject flake8 flake8-docstrings flake8-isort
And then run it on files or directories that you want to check:
$ flake8 my_project
my_project/setup.py:40:80: E501 line too long (103 > 79 characters)
my_project/tests/test_my_project.py:9:1: F401 'my_project.some_function' imported but unused
my_project/my_project/some_file.py:1:7: F821 undefined name 'my_var'
Of course, the best way to use Flake8 is to enable is directly in your code editor. VS Code will offer you this option when you open a Python file, but if it doesn’t, run the Python: Select Linter command from the command pallet (ctrl + shit + p generally).
Review addition. The following command installs the pip packages in one line:
pip install -U flake8 flake8-docstrings flake8-isort