summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/pyformat.py
blob: 14644438045562271c2a3e31cd751f13915bd8e1 (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.", hidden=False if cli.config.user.developer else True)
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!')