Skip to content
check-circle

GitHub Action

YAPF Python Code Formatter

v1.1 Latest version

YAPF Python Code Formatter

check-circle

YAPF Python Code Formatter

Run YAPF to format your python code

Installation

Copy and paste the following snippet into your .yml file.

              

- name: YAPF Python Code Formatter

uses: block42-blockchain-company/[email protected]

Learn more about this action in block42-blockchain-company/yapf-action

Choose a version

YAPF Python Code Formatter

Forked from Alexander Melde's repo

GitHub issues GitHub license GitHub stars

A GitHub action that runs YAPF to format your python code.

Once Configured, your action workflow will succeed only if your code is formatted in YAPF style.

The action runs yapf:

  • SUCCESS: exit-code=zero → code got YAPF-formatted
  • FAIL: exit-code=non-zero → syntax or program error

Usage

To use this action in your repository, create a file like .github/workflows/yapf_check.yml with the following content:

name: YAPF Formatting Check
on: [push]
jobs:
  formatting-check:
    name: Formatting Check
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: run YAPF to format the python code
      uses: block42-blockchain-company/yapf-action
      with:
        args: --verbose

You can pass any other YAPF parameter using the args setting, e.g. for setting a different code style (default is PEP8), but you can also remove the with section entirely if you wish.

If you want to exclude a certain directory, you can use the args field like this: args: --verbose --exclude '**/tests/**'. Thank you @pksol for the example.