summaryrefslogtreecommitdiff
path: root/lib/python/qmk
diff options
context:
space:
mode:
authorskullY <skullydazed@gmail.com>2019-08-22 09:40:12 -0700
committerFlorian Didron <fdidron@users.noreply.github.com>2019-10-01 10:21:12 +0900
commitff7a7adbcf567ecc2110662a1f1063d0e68e593f (patch)
tree106feb3f0b2be9e87650345913bb3caf3a6a3ea6 /lib/python/qmk
parente079d58b7d35cdb37c36b040c97c94f5cdce7194 (diff)
Add a command to format python code
Diffstat (limited to 'lib/python/qmk')
-rwxr-xr-xlib/python/qmk/cli/pyformat.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/python/qmk/cli/pyformat.py b/lib/python/qmk/cli/pyformat.py
new file mode 100755
index 0000000000..b1f8c02b28
--- /dev/null
+++ b/lib/python/qmk/cli/pyformat.py
@@ -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!')