-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoxfile.py
More file actions
105 lines (82 loc) · 2.89 KB
/
noxfile.py
File metadata and controls
105 lines (82 loc) · 2.89 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""
noxfile.py Configuration file for Nox
"""
# pylint: disable=import-error
import os
import shutil
import nox
nox.options.error_on_external_run = True
nox.options.envdir = os.environ.get("NOX_ENVDIR", ".nox")
@nox.session(reuse_venv=True, default=False)
def build_venv(session):
"""Builds the virtual environment."""
session.install("-e", ".[dev]")
if session.posargs:
for task in session.posargs[0]:
task(session, *session.posargs[1:])
@nox.session(default=False, python=False)
def clean(session):
"""Clean up build artifacts."""
session.log(f"Removing build artifacts from '{nox.options.envdir}'")
shutil.rmtree(nox.options.envdir, ignore_errors=True)
@nox.session(reuse_venv=True, default=False)
def cli(session):
"""Runs the CLI."""
session.notify("build_venv", posargs=([_cli], *session.posargs))
@nox.session(reuse_venv=True)
def lint(session):
"""Runs lint checks."""
session.notify("build_venv", posargs=([_lint], *session.posargs))
@nox.session(reuse_venv=True)
def style(session):
"""Runs linters and fixers."""
session.notify("build_venv", posargs=([_style], *session.posargs))
@nox.session(reuse_venv=True)
def test(session):
"""Runs tests."""
session.notify("build_venv", posargs=([_test], *session.posargs))
def _cli(session, *args):
"""Executes the environment command for the CLI."""
if session.posargs:
session.run(*args)
def _lint(session):
"""Executes the environment command for the lint checks."""
session.run("black", "--check", "--diff", "--color", ".")
session.run("flake8", "src", "test")
session.run("isort", "--check", "--diff", "--color", "--profile", "black", ".")
session.run("pyprojectsort", "--diff")
session.run("ruff", "check", "src")
session.run("ruff", "check", "test", "--ignore=D,S101,PLR2004")
session.run("pylint", "--enable-all-extensions", "src")
session.run(
"pylint",
"--enable-all-extensions",
"test",
"--disable=duplicate-code",
"--disable=magic-value-comparison",
"--disable=missing-class-docstring",
"--disable=missing-function-docstring",
"--disable=missing-module-docstring",
"--disable=missing-param-doc",
"--disable=missing-return-doc",
"--disable=missing-yield-doc",
)
session.run("mypy", "src", "test")
def _style(session):
"""Executes the environment command for the stylers and fixers."""
session.run("black", "--verbose", ".")
session.run("isort", "--profile", "black", ".")
session.run("pyprojectsort")
def _test(session, *args):
"""Executes the environment command for the tests."""
session.run(
"coverage",
"run",
"--source=src,test",
"-m",
"pytest",
"--capture=sys",
"-v",
*args,
)
session.run("coverage", "report", "--fail-under=100", "--show-missing")