summaryrefslogtreecommitdiffstats
path: root/lib/python/qmk/cli/pyformat.py
blob: a53ba40c0a686cee41595cc05a3c3d3b21a85e02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Format python code according to QMK's style.
"""
from milc import cli

import subprocess


@cli.subcommand("Format python code according to QMK's style.")
def pyformat(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!')