We use YAPF to check Python code style and apply automatic formatting. We plan to move to black.
Code should conform to PEP8, the style guide for Python code.
YAPF goes beyond that and applies stylistic changes as configured in the style file
Our maximal line length is 120 but we want to reduce it to 88, the black default.
Auto-Formatting Python Code
Running yapf -dr src shows a diff for the entire source directory. yapf -ir src formats everything in-place (git commit first!).
An alias to auto-format only changed files as seen by Git may be helpful:
alias py-format-changed="git ls-files -m --others --exclude-standard | grep '\.py$' | xargs yapf -i"
If you want each list value to stay on a separate line, use a trailing comma after
the last element (here after
model_properties = [ 'abstract', 'author', 'ballot', 'content', 'created_at', ]