]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add a command to format python code
authorskullY <skullydazed@gmail.com>
Thu, 22 Aug 2019 16:40:12 +0000 (09:40 -0700)
committerskullydazed <skullydazed@users.noreply.github.com>
Sat, 7 Sep 2019 14:58:41 +0000 (07:58 -0700)
lib/python/qmk/cli/pyformat.py [new file with mode: 0755]

diff --git a/lib/python/qmk/cli/pyformat.py b/lib/python/qmk/cli/pyformat.py
new file mode 100755 (executable)
index 0000000..b1f8c02
--- /dev/null
@@ -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!')