forked from viktorbesin/newground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
52 lines (42 loc) · 1.24 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
import os
import nox
# default sessions that shall be run
nox.options.sessions = ["lint_pylint", "lint_flake8"]
EDITABLE_TESTS = True
PYTHON_VERSIONS = None
if "GITHUB_ACTIONS" in os.environ:
PYTHON_VERSIONS = ["3.11"]
EDITABLE_TESTS = False
@nox.session
def lint_flake8(session):
session.install("-e", ".[lint_flake8]")
session.run("flake8", "newground")
@nox.session
def lint_pylint(session):
session.install("-e", ".[lint_pylint]")
session.run("pylint", "newground")
@nox.session
def format(session):
session.install("-e", ".[format]")
check = "check" in session.posargs
autoflake_args = [
"--in-place",
"--imports=fillname",
"--ignore-init-module-imports",
"--remove-unused-variables",
"-r",
"newground",
]
if check:
autoflake_args.remove("--in-place")
session.run("autoflake", *autoflake_args)
isort_args = ["--profile", "black", "newground"]
if check:
isort_args.insert(0, "--check")
isort_args.insert(1, "--diff")
session.run("isort", *isort_args)
black_args = ["newground"]
if check:
black_args.insert(0, "--check")
black_args.insert(1, "--diff")
session.run("black", *black_args)