-
Notifications
You must be signed in to change notification settings - Fork 0
/
poetry_scripts.py
57 lines (37 loc) · 1.09 KB
/
poetry_scripts.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from __future__ import annotations
import argparse
import subprocess
from pathlib import Path
HOME_PATH = Path(__file__).parent
"""
CI scripts
"""
def isort(check: bool = False) -> None:
check_cmd = ["--check"] if check else []
subprocess.run(["isort", "."] + check_cmd, check=True)
def black(check: bool = False) -> None:
check_cmd = ["--check"] if check else []
subprocess.run(["black", "."] + check_cmd, check=True)
def flake8() -> None:
subprocess.run(["flake8"], check=True)
def mypy() -> None:
subprocess.run(["mypy", "."], check=True)
def test() -> None:
subprocess.run(["pytest"], check=True)
def style() -> None:
parser = argparse.ArgumentParser(description="Style.")
parser.add_argument(
"--check",
action="store_true",
help="error if failing style",
)
args = parser.parse_args()
isort(check=args.check)
black(check=args.check)
flake8()
mypy()
def remove_unused() -> None:
subprocess.run(
["autoflake", "--in-place", "--remove-all-unused-imports", "-r", "."],
check=True,
)