-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtasks.py
47 lines (34 loc) · 1.13 KB
/
tasks.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
#!/usr/bin/env python3
"""Development tasks for convenience."""
from invoke import Collection, Task, task
@task
def format(c):
"""Format the code to make it compatible with the `check` command."""
print("> sorting imports]")
c.run("isort .")
print("> [painting all the code black]")
c.run("black .")
@task
def test(c, aliases=["pytest"]):
"""Run all tests using pytest."""
print("")
print("[running pytest]")
c.run("coverage run -m pytest")
c.run("coverage report")
@task
def check(c):
"""Check the code is ok by running flake8, black, isort and mypy."""
print("> check that code is formatted well")
c.run("black --check .")
c.run("isort --check-only .")
print("> lint with flake8")
c.run("flake8")
print("> typecheck")
c.run("mypy .")
@task(pre=[format, check, test])
def all(c):
"""Run format, check and test all in one command."""
# Configure default collection to change default pty setting
# Pytest will run much nicer if pty is set to true.
ns = Collection(*(item for item in locals().values() if isinstance(item, Task)))
ns.configure({"run": {"pty": True}})