aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python/qmk/cli/pyformat.py
blob: b1f8c02b2816334a85030d6bffe774c1918950dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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!')