Python Black Formatter - Only on Edited Files
ActionsThis is a github action that will run the black python formatter on a PR, but only on the files changed in your PR. This helps avoid situations where one runs the formatter on an old code base and gets hundreds of files with warnings and hints. Entrypoint code is inspired by the excellent typilus.
To install, create a GitHub Actions Workflow:
name: Black Check
# Run action on PRs to master
on:
pull_request:
branches: [ master ]
jobs:
suggest:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so that black can inspect it
- uses: actions/checkout@v2
- uses: rgasper/python-black-pull-request-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
By default, runs black with all default configurations except for --line-length 130
, because 88 characters feels a bit small. This can be changed by assigning the argument in the Workflow.
etc...
- uses: rgasper/python-black-pull-request-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINE_LENGTH: 1000 # please don't do this
Python Black Formatter - Only on Edited Files is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.