-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoetry_scripts.py
More file actions
45 lines (31 loc) · 934 Bytes
/
poetry_scripts.py
File metadata and controls
45 lines (31 loc) · 934 Bytes
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
import subprocess
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 style() -> None:
isort()
black()
flake8()
mypy()
def style_check() -> None:
isort(check=True)
black(check=True)
flake8()
mypy()
def remove_unused() -> None:
print(
"Warning - this is a somewhat dangerous operation."
" It can remove imports with side-effects."
" Know what you've changed"
)
subprocess.run(
["autoflake", "--in-place", "--remove-all-unused-imports", "-r", "."],
check=True,
)