-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
41 lines (30 loc) · 943 Bytes
/
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
from invoke import task
import multiprocessing
import sys
import toml
pty = sys.stdout.isatty()
def get_package_name() -> str:
pyproject = toml.load(open('pyproject.toml', 'r'))
return pyproject['tool']['poetry']['name']
@task
def lint(c):
package_name = get_package_name()
nproc = multiprocessing.cpu_count()
c.run(f'mypy {package_name}.py tests', echo=True, pty=pty)
c.run(f'pylint --jobs {nproc} {package_name} tests', echo=True, pty=pty)
c.run(f'pydocstyle {package_name} tests', echo=True, pty=pty)
@task
def test(c):
package_name = get_package_name()
c.run(
f'pytest --cov={package_name} --doctest-modules --ignore=docs --ignore=tasks.py',
echo=True,
pty=pty)
@task
def html(c):
c.run('make -C docs html', echo=True, pty=pty)
@task
def serve(c):
c.run('sphinx-autobuild docs docs/_build/html --host 0.0.0.0 --watch .',
echo=True,
pty=pty)