-
Notifications
You must be signed in to change notification settings - Fork 1
/
noxfile.py
37 lines (28 loc) · 1.19 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
import os
import nox
from nox import options
PATH_TO_PROJECT = os.path.join(".", "src")
SCRIPT_PATHS = [PATH_TO_PROJECT, "noxfile.py"]
# Run the default session via 'nox'
options.sessions = ["format_fix", "pyright"]
# Run me via 'nox -s format_fix'
# Format the code and fix any issues, useful for local development
@nox.session()
def format_fix(session: nox.Session) -> None:
session.install("-U", "ruff", "-c", "dev_requirements.txt")
session.run("python", "-m", "ruff", "format", *SCRIPT_PATHS)
session.run("python", "-m", "ruff", "check", *SCRIPT_PATHS, "--fix")
# Run me via 'nox -s format'
# Checks if the code is formatted correctly, useful for CI
@nox.session()
def format(session: nox.Session) -> None:
session.install("-U", "ruff", "-c", "dev_requirements.txt")
session.run("python", "-m", "ruff", "format", *SCRIPT_PATHS, "--check")
session.run("python", "-m", "ruff", "check", *SCRIPT_PATHS)
# Run me via 'nox -s pyright'
# Runs the pyright static type checker
@nox.session()
def pyright(session: nox.Session) -> None:
session.install("-r", "requirements.txt")
session.install("-U", "pyright", "-c", "dev_requirements.txt")
session.run("pyright", PATH_TO_PROJECT)