-
Notifications
You must be signed in to change notification settings - Fork 2
/
noxfile.py
55 lines (46 loc) · 1.41 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
"""Automated testing linting and formatting apparatus."""
# external
import nox
from nox.sessions import Session
package = "polanyi"
nox.options.sessions = "lint", "tests", "mypy" # default session
locations = "polanyi", "tests", "noxfile.py" # Linting locations
pyversions = ["3.8", "3.9"]
# Testing
@nox.session(python=pyversions)
def tests(session: Session) -> None:
"""Run tests."""
args = session.posargs + ["--cov=morfeus", "--import-mode=importlib", "-s"]
session.install("-r", "requirements.txt")
session.install("pytest", "pytest-cov")
session.install("-e", ".", "--no-deps")
session.run("pytest", *args)
# Linting
@nox.session(python="3.9")
def lint(session: Session) -> None:
"""Lint code."""
args = session.posargs or locations
session.install(
"flake8",
"flake8-black",
"flake8-bugbear",
"flake8-import-order",
"flake8-annotations",
"flake8-docstrings",
"darglint",
)
session.run("flake8", *args)
# Code formatting
@nox.session(python="3.9")
def black(session: Session) -> None:
"""Format code."""
args = session.posargs or locations
session.install("black")
session.run("black", *args)
# Static typing
@nox.session(python="3.9")
def mypy(session: Session) -> None:
"""Run the static type checker."""
args = session.posargs or locations
session.install("mypy")
session.run("mypy", *args)