-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathstyle.py
45 lines (30 loc) · 1.05 KB
/
style.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
from invoke.context import Context
from invoke.tasks import task
from tasks.common import COMMON_TARGETS_AS_STR, VENV_PREFIX
@task
def ruff(ctx: Context) -> None:
"""Check style through ruff"""
ctx.run(f"{VENV_PREFIX} ruff check {COMMON_TARGETS_AS_STR}")
@task
def mypy(ctx: Context) -> None:
"""Check style through mypy"""
ctx.run(f"{VENV_PREFIX} mypy")
@task
def black_check(ctx: Context) -> None:
"""Check style through black"""
ctx.run(f"{VENV_PREFIX} black --check {COMMON_TARGETS_AS_STR}")
@task
def commit_check(ctx):
"""Check commit message through commitizen"""
ctx.run(f"{VENV_PREFIX} cz -nr 3 check --rev-range v0.1.1..", warn=True)
@task(pre=[ruff, mypy, black_check, commit_check], default=True)
def run(ctx: Context) -> None:
"""Check style through linter (Note that pylint is not included)"""
pass
@task
def black(ctx):
ctx.run(f"{VENV_PREFIX} black {COMMON_TARGETS_AS_STR}")
@task(pre=[ruff, black])
def reformat(ctx: Context) -> None:
"""Reformat python files through black and ruff"""
pass