forked from frequenz-floss/frequenz-channels-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
84 lines (65 loc) · 2.13 KB
/
noxfile.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# License: MIT
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
"""Code quality checks."""
import nox
check_dirs = [
"benchmarks",
"docs",
"src",
"tests",
]
check_files = [
"noxfile.py",
]
@nox.session
def formatting(session: nox.Session) -> None:
"""Run black and isort to make sure the format is uniform."""
session.install("black", "isort")
session.run("black", "--check", *check_dirs, *check_files)
session.run("isort", "--check", *check_dirs, *check_files)
@nox.session
def pylint(session: nox.Session) -> None:
"""Run pylint to do lint checks."""
session.install("-e", ".[docs]", "pylint", "pytest", "nox")
session.run("pylint", *check_dirs, *check_files)
@nox.session
def mypy(session: nox.Session) -> None:
"""Run mypy to check type hints."""
session.install("-e", ".[docs]", "pytest", "nox", "mypy")
common_args = [
"--namespace-packages",
"--non-interactive",
"--install-types",
"--explicit-package-bases",
"--strict",
]
pkg_args = []
for pkg in check_dirs:
if pkg == "src":
pkg = "frequenz.channels"
pkg_args.append("-p")
pkg_args.append(pkg)
session.run("mypy", *common_args, *pkg_args)
session.run("mypy", *common_args, *check_files)
@nox.session
def docstrings(session: nox.Session) -> None:
"""Check docstring tone with pydocstyle and param descriptions with darglint."""
session.install("pydocstyle", "darglint", "toml")
session.run("pydocstyle", *check_dirs, *check_files)
# Darglint checks that function argument and return values are documented.
# This is needed only for the `src` dir, so we exclude the other top level
# dirs that contain code.
session.run("darglint", "src")
@nox.session
def pytest(session: nox.Session) -> None:
"""Run all tests using pytest."""
session.install("pytest", "pytest-cov", "pytest-mock", "pytest-asyncio")
session.install("-e", ".")
session.run(
"pytest",
"-W=all",
"-vv",
"--cov=frequenz.channels",
"--cov-report=term",
"--cov-report=html:.htmlcov",
)