-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_lint.py
31 lines (23 loc) · 821 Bytes
/
run_lint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import argparse
import os
import subprocess
import sys
def main():
base_dir = os.path.dirname(__file__)
if base_dir:
os.chdir(base_dir)
parser = argparse.ArgumentParser(description="Run linters and formatters.")
parser.add_argument("--check", action="store_true", help="Only run formatters in check mode")
args = parser.parse_args()
failed = False
isort_args = ""
black_args = ""
if args.check:
isort_args = "--check-only"
black_args = "--check"
failed |= subprocess.call(f"isort . {isort_args}", shell=True) > 0
failed |= subprocess.call(f"black . --config black.toml {black_args}", shell=True) > 0
failed |= subprocess.call("flake8 . --exclude .idea", shell=True) > 0
sys.exit(1 if failed else 0)
if __name__ == '__main__':
main()