@@ -16,6 +16,9 @@ CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
16
16
LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt"
17
17
PACKAGE_NAME = subprocess.check_output([sys.executable, "setup.py", "--name"], encoding="utf-8")
18
18
19
+ BLACK_VERSION = "black==19.10b0"
20
+ BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"]
21
+ DEFAULT_PYTHON_VERSION = "3.9"
19
22
20
23
nox.sessions = [
21
24
"unit",
@@ -24,6 +27,9 @@ nox.sessions = [
24
27
"check_lower_bounds"
25
28
# exclude update_lower_bounds from default
26
29
"docs",
30
+ "blacken",
31
+ "lint",
32
+ "lint_setup_py",
27
33
]
28
34
29
35
@nox.session(python=['3.6', '3.7', '3.8', '3.9', '3.10'])
@@ -44,7 +50,7 @@ def unit(session):
44
50
)
45
51
46
52
47
- @nox.session(python='3.9' )
53
+ @nox.session(python=DEFAULT_PYTHON_VERSION )
48
54
def cover(session):
49
55
"""Run the final coverage report.
50
56
This outputs the coverage report aggregating coverage from the unit
@@ -103,7 +109,7 @@ def check_lower_bounds(session):
103
109
str(LOWER_BOUND_CONSTRAINTS_FILE),
104
110
)
105
111
106
- @nox.session(python='3.9' )
112
+ @nox.session(python=DEFAULT_PYTHON_VERSION )
107
113
def docs(session):
108
114
"""Build the docs for this library."""
109
115
@@ -123,4 +129,38 @@ def docs(session):
123
129
os.path.join("docs", ""),
124
130
os.path.join("docs", "_build", "html", ""),
125
131
)
132
+
133
+
134
+ @nox.session(python=DEFAULT_PYTHON_VERSION)
135
+ def lint(session):
136
+ """Run linters.
137
+
138
+ Returns a failure if the linters find linting errors or sufficiently
139
+ serious code quality issues.
140
+ """
141
+ session.install("flake8", BLACK_VERSION)
142
+ session.run(
143
+ "black",
144
+ "--check",
145
+ *BLACK_PATHS,
146
+ )
147
+ session.run("flake8", "google", "tests", "samples")
148
+
149
+
150
+ @nox.session(python=DEFAULT_PYTHON_VERSION)
151
+ def blacken(session):
152
+ """Run black. Format code to uniform standard."""
153
+ session.install(BLACK_VERSION)
154
+ session.run(
155
+ "black",
156
+ *BLACK_PATHS,
157
+ )
158
+
159
+
160
+ @nox.session(python=DEFAULT_PYTHON_VERSION)
161
+ def lint_setup_py(session):
162
+ """Verify that setup.py is valid (including RST check)."""
163
+ session.install("docutils", "pygments")
164
+ session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
165
+
126
166
{% endblock %}
0 commit comments