forked from digital-chemistry-laboratory/morfeus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
58 lines (47 loc) · 1.45 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
"""Automated testing linting and formatting apparatus."""
from __future__ import annotations
import nox
from nox.sessions import Session
package = "morfeus"
nox.options.sessions = "lint", "tests", "mypy" # default session
locations = "morfeus", "tests", "noxfile.py" # Linting locations
pyversions = ["3.8", "3.9", "3.10"]
# Testing
@nox.session(python=pyversions)
def tests(session: Session) -> None:
"""Run tests."""
args = session.posargs + ["--cov=morfeus", "--import-mode=importlib", "-s"]
session.install("pytest", "pytest-cov")
session.install(".")
session.run("pytest", *args)
# Linting
@nox.session(python="3.10")
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.10")
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.10")
def mypy(session: Session) -> None:
"""Run the static type checker."""
args = session.posargs or locations
session.install("mypy")
session.install("numpy")
session.install("types-setuptools")
session.run("mypy", *args)