~ruther/qmk_firmware

deb6fa6a87b12fcdbf577837c6faeb854cd287c7 — skullY 6 years ago 533d6d6
Add a command to format python code
1 files changed, 16 insertions(+), 0 deletions(-)

A lib/python/qmk/cli/pyformat.py
A lib/python/qmk/cli/pyformat.py => lib/python/qmk/cli/pyformat.py +16 -0
@@ 0,0 1,16 @@
"""Format python code according to QMK's style.
"""
from milc import cli

import subprocess


@cli.entrypoint("Format python code according to QMK's style.")
def main(cli):
    """Format python code according to QMK's style.
    """
    try:
        subprocess.run(['yapf', '-vv', '-ri', 'bin/qmk', 'lib/python'], check=True)
        cli.log.info('Successfully formatted the python code in `bin/qmk` and `lib/python`.')
    except subprocess.CalledProcessError:
        cli.log.error('Error formatting python code!')