Skip to content

Python Black Formatter - Only on Edited Files

Actions
Runs python black formatter but only on files that were changed the given PR
1.1.1
Latest
Star (4)

Readme

This 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.

Installation

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 }}

Configuration

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.

About

Runs python black formatter but only on files that were changed the given PR
1.1.1
Latest

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.