Git Product home page Git Product logo

yapf-action's Introduction

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/yapf-action@master
      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.

yapf-action's People

Contributors

alexandermelde avatar ptxmac avatar wildcard65 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yapf-action's Issues

Add an example of excluding folders from yapf to the documentation

I wanted to ignore my tests folder, so I had to hack a bit till I got to this way:

args: --verbose --exclude '**/tests/**' (the trivial way would be to send just 'tests/**' as a parameter, but it assumes that the execution is inside the repository).

Can you include it to the documentation so people can use it quickly? I didn't do a pull request in case you wanted to solve it in a different way.

Fix "yapf not found" in PR #3

see #3 for details, unfortunately i dont't have the time to investigate further into it currently, so @WildCard65 if you want to fix the bug, please send a new pull request if you have resolved the issue ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.