clean-code-python
clean-code-python copied to clipboard
Apply blacken-docs / the black code formatter
Black is becomming the de-facto standard for code formatting in Python. It makes sure code looks similar in many projects and it leads to minimal diffs.
Makes sense. Before I merge this, I'll take a look at integrating Black via its API so tests fail if it detects any style errors. Bear with me...
You can add a Github Action by creating .github/workflows/linting.yaml with the content:
name: Lint
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install blacken-docs
- name: Test with blacken-docs
run: |
blacken-docs .
However, I'm uncertain if that will give a non-zero exit code when the check is run.