Coding Style for python Code#
The code has to be compliant with PEP8 rules as well as with python coding style.
Recommendations#
Configure properly IDE to detect PEP8 error
Run the tool
isort
to organise properly module importsRun the python code formatter
black
Run the tool
flake8
to detect PEP8 violationPyCharm can be configured to run
isort
andblack
each time a file is saved
Check your code#
Check that your code is compliant with coding style and PEP8 (replace
xxx
byqa
,uc
,model
, etc.):(venv) $ cd p400-xxx (venv) $ isort --check-only -v p400xxx (venv) $ black --diff --color p400xxx (venv) $ flake8 src
Correct your code#
Correct remaining PEP8 violation via your IDE
Modify python files to be compliant with coding style:
(venv) $ cd p400-xxx (venv) $ isort -v p400xxx (venv) $ black p400xx
It can be automatize in PyCharm, each time a file is saved.
Test your code and commit your changes
GitLab Continuous Integration#
Coding style and PEP8 rules are checked when a merge request is triggered in GitLab. The merge request can only be accepted if checks are successful