generated from potassco/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
88 lines (67 loc) · 2.21 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
85
86
87
88
import os
import nox
nox.options.sessions = "lint_flake8", "lint_pylint", "typecheck", "test"
EDITABLE_TESTS = True
PYTHON_VERSIONS = None
if "GITHUB_ACTIONS" in os.environ:
PYTHON_VERSIONS = ["3.7", "3.11"]
EDITABLE_TESTS = False
@nox.session
def format(session):
session.install("-e", ".[format]", "-r", "requirements.txt")
check = "check" in session.posargs
autoflake_args = [
"--in-place",
"--imports=memelingo",
"--ignore-init-module-imports",
"--remove-unused-variables",
"-r",
"src",
"tests",
]
if check:
autoflake_args.remove("--in-place")
session.run("autoflake", *autoflake_args)
isort_args = ["--profile", "black", "src", "tests"]
if check:
isort_args.insert(0, "--check")
isort_args.insert(1, "--diff")
session.run("isort", *isort_args)
black_args = ["src", "tests"]
if check:
black_args.insert(0, "--check")
black_args.insert(1, "--diff")
session.run("black", *black_args)
@nox.session
def doc(session):
target = "html"
options = []
if session.posargs:
target = session.posargs[0]
options = session.posargs[1:]
session.install("-e", ".[doc]", "-r", "requirements.txt")
session.cd("doc")
session.run("sphinx-build", "-M", target, ".", "_build", *options)
@nox.session
def lint_flake8(session):
session.install("-e", ".[lint_flake8]", "-r", "requirements.txt")
session.run("flake8", "src", "tests")
@nox.session
def lint_pylint(session):
session.install("-e", ".[lint_pylint]", "-r", "requirements.txt")
session.run("pylint", "memelingo", "tests")
@nox.session
def typecheck(session):
session.install("-e", ".[typecheck]", "-r", "requirements.txt")
session.run("mypy", "-p", "memelingo", "-p", "tests")
@nox.session(python=PYTHON_VERSIONS)
def test(session):
args = ['.[test]', "-r", "requirements.txt"]
if EDITABLE_TESTS:
args.insert(0, '-e')
session.install(*args)
session.run("coverage", "run", "-m", "unittest", "discover", "-v")
session.run("coverage", "report", "-m", "--fail-under=100")
@nox.session
def dev(session):
session.install("-e", ".[dev]", "-r", "requirements.txt")