User Tools

Site Tools


dod_python

Coding Style Requirements for python projects

We are working with Python version 3.11. If a project needs or uses another version it must be specified in the README.md and it needs to be explained why the version is different from the specified version.

the source code is formatted according to black (black==23.9.1) (a python formatting tool). we use this tool in a specific version to reduce the reformatting noise in merge requests.

the imports are managed by isort (see configuration below)

the code is checked by flake8 and there should be no errors or warnings. by keeping the warnings and errors at zero, we get better information during the development of new features.

Note: reformatting changes should not be part of the merge request

each project needs a setup.cfg file with at least the following contents

[flake8]
ignore = E203, E266, E501, W503, F403, F405
max-line-length = 160
max-complexity = 18
select = B,C,E,F,W,T4
exclude =
.git
disabled_tests
experiments

[isort]
profile=black

[tool:pytest]
testpaths=tests/

Notes

  • the specific versions can be changed if all developers on the specific project agree to it. the versions of the tools need to be apparent within the project (SETUP.md, requirements-dev.txt, Pipfile)
dod_python.txt · Last modified: 2024/04/11 14:23 by 127.0.0.1