Skip to content

Code Formatting Using Black and Flake8

Shiyang Pan edited this page Dec 17, 2023 · 2 revisions

A GitHub action has been set up to test the code format for every git push on main and dev branch, so it'll be better to fix the format error before pushing your code.

Install dependencies

Run pip install -e .[lint] in terminal

Before pushing your code to dev or main branch

Locate at the root directory of improv to trigger the black and flake8 customized configuration. Otherwise both will use their default configuration and cause potential conflict

1. Use black to automatically format code

Run black path_to_your_file

2. Use flake8 to catch remaining code format error

Run flake8 path_to_your_file

then manually fix all reported format error

3. Use black to check the code again

black path_to_your_file

After pushing your code

If there is any test failed in the action workflow, fix flake8 error reported in the workflow, redo steps in 'Before commit your code' section and push your code again

Clone this wiki locally