Skip to content

Commit 58366b9

Browse files
authored
Include ./tests in nox lint session (#200)
* Simplify install steps * Handle running lint session on tests/
1 parent 9a8db54 commit 58366b9

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

noxfile.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,25 @@
1616
LINT_PATH = "./src"
1717
REQUIREMENTS_PATH = "./requirements"
1818

19+
20+
LINTING_COMMANDS = (
21+
(
22+
"isort",
23+
"--verbose",
24+
"--force-single-line-imports",
25+
"--profile",
26+
"black",
27+
"--add-import",
28+
"from __future__ import annotations",
29+
LINT_PATH,
30+
TESTS_PATH,
31+
),
32+
("black", "--verbose", LINT_PATH, TESTS_PATH),
33+
("flake8", "--show-source", "--verbose", LINT_PATH, TESTS_PATH),
34+
("mypy", "--no-incremental", "--package", MODULE_NAME),
35+
("mypy", "--no-incremental", TESTS_PATH),
36+
)
37+
1938
# What we allowed to clean (delete)
2039
CLEANABLE_TARGETS = [
2140
"./dist",
@@ -55,10 +74,7 @@ def dev(session: nox.Session) -> None:
5574
python = partial(session.run, f"{venv_path}/python", "-m")
5675
contraint = ("--constraint", f"{REQUIREMENTS_PATH}/constraints.txt")
5776

58-
for requirement_file in get_requirement_files():
59-
python("pip", "install", "-r", requirement_file, *contraint, external=True)
60-
61-
python("pip", "install", "--editable", ".", *contraint, external=True)
77+
python("pip", "install", "--editable", ".[dev,test]", *contraint, external=True)
6278

6379
python("pip", "install", "pre-commit", external=True)
6480
session.run(f"{venv_path}/pre-commit", "install", external=True)
@@ -109,26 +125,12 @@ def run_linters_and_formatters(session: nox.Session) -> None:
109125
print_standard_logs(session)
110126

111127
contraint = ("--constraint", f"{REQUIREMENTS_PATH}/constraints.txt")
112-
session.install(".[dev]", *contraint)
128+
session.install(".[dev,test]", *contraint)
113129

114130
python = partial(session.run, "python", "-m")
115131

116-
# Handle anything tool that applies corrections first.
117-
python(
118-
"isort",
119-
"--verbose",
120-
"--force-single-line-imports",
121-
"--profile",
122-
"black",
123-
"--add-import",
124-
"from __future__ import annotations",
125-
LINT_PATH,
126-
)
127-
python("black", "--verbose", LINT_PATH)
128-
129-
# Linters: aka, things that yell but want you to fix things
130-
python("flake8", "--show-source", "--verbose", LINT_PATH)
131-
python("mypy", "--no-incremental", "--package", MODULE_NAME)
132+
for linter_command in LINTING_COMMANDS:
133+
python(*linter_command)
132134

133135

134136
@nox.session()

0 commit comments

Comments
 (0)