Skip to content

Commit 10e49e1

Browse files
committed
invoke tasks
1 parent 86cba74 commit 10e49e1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tasks.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
tasks.py
3+
--------
4+
Project invoke tasks
5+
6+
Available commands
7+
invoke --list
8+
invoke fmt
9+
invoke sort
10+
"""
11+
import invoke
12+
13+
TARGETS_DESCRIPTION = "Paths/directories to format. [default: . ]"
14+
15+
16+
@invoke.task(help={"targets": TARGETS_DESCRIPTION})
17+
def sort(ctx, targets="."):
18+
"""Sort module imports."""
19+
print("sorting imports ...")
20+
args = ["isort", "-rc", "--atomic", targets]
21+
ctx.run(" ".join(args))
22+
23+
24+
@invoke.task(pre=[sort], help={"targets": TARGETS_DESCRIPTION})
25+
def fmt(ctx, targets="."):
26+
"""Format python source code & sort imports."""
27+
print("formatting ...")
28+
args = ["black", targets]
29+
ctx.run(" ".join(args))

0 commit comments

Comments
 (0)