Skip to content

YAPF Python Code Formatting Check

Actions
Run YAPF to check if your python code is correctly formatted
v2.0
Latest
Star (23)

YAPF Python Code Formatting Check

GitHub issues GitHub license Winner Of The GitHub Actions Hackathon GitHub stars

A GitHub action that runs YAPF to test if your python code is correctly formatted.

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

The action uses the --diff parameter of YAPF in order to return:

  • SUCCESS: exit-code=zero → no changes were necessary, code is YAPF-formatted
  • FAIL: exit-code=non-zero → not correctly formatted 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 test if python code is correctly formatted
      uses: AlexanderMelde/[email protected]
      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 file or directory, you can either use the --exclude parameter or a .yapfignore file.

Migration Notice

Earlier versions of this action did not set the working directory before executing yapf.

If you used the --exclude '**/tests/**' workaround, you might need to simplify this to --exclude 'tests/**' now.

YAPF Python Code Formatting Check 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

Run YAPF to check if your python code is correctly formatted
v2.0
Latest

YAPF Python Code Formatting Check 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.