Skip to content

A GitHub Action that runs the Python Black formatter but only on files that changed in the PR

License

Notifications You must be signed in to change notification settings

da-amit-mujawar/python-black-pull-request-action

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A GitHub Action that runs the Python Black formatter but only on files that changed in the PR

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 82.8%
  • Dockerfile 17.2%