-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnoxfile.py
More file actions
51 lines (37 loc) · 1.42 KB
/
noxfile.py
File metadata and controls
51 lines (37 loc) · 1.42 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
import nox
nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = ("lint", "test")
SRC = "mindmap"
def format_with_args(session: nox.Session, *args):
session.run("autoflake", *args)
session.run("isort", *args)
session.run("black", *args)
MIN_PYTHON_VERSION = "3.11"
@nox.session(python=[MIN_PYTHON_VERSION])
def lint(session: nox.Session):
"""Runs linters and fixers"""
try:
session.run("poetry", "install", external=True)
session.run("poetry", "check", "--lock", external=True)
session.run("pyright", SRC)
session.run("flake8", SRC)
format_with_args(session, SRC, "--check")
except Exception:
session.error(
"linting has failed. Run 'make format' to fix formatting and fix other errors manually"
)
@nox.session(python=[MIN_PYTHON_VERSION])
def format(session: nox.Session):
"""Runs linters and fixers"""
session.run("poetry", "install", external=True)
format_with_args(session, SRC)
@nox.session(python=[MIN_PYTHON_VERSION])
def test(session: nox.Session):
"""Runs unit tests"""
session.run("poetry", "install", external=True)
session.run("pytest", "tests/unit_tests/")
@nox.session(python=[MIN_PYTHON_VERSION])
def update_graph(session: nox.Session):
"""Runs unit tests"""
session.run("poetry", "install", "--with=update_data", external=True)
session.run("python", "./update_data/update_graph.py")