Skip to content

Commit 925bafd

Browse files
crwilcoxdhermes
authored andcommitted
Lint NDB on CI (#6822)
1 parent 8f4c76f commit 925bafd

4 files changed

Lines changed: 35 additions & 14 deletions

File tree

noxfile.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,41 @@ def cover(session):
6868
session.run("coverage", "erase")
6969

7070

71+
def run_black(session, use_check=False):
72+
args = ["black"]
73+
if use_check:
74+
args.append("--check")
75+
76+
args.extend(
77+
[
78+
"--line-length=79",
79+
get_path("docs"),
80+
get_path("noxfile.py"),
81+
get_path("src"),
82+
get_path("tests"),
83+
]
84+
)
85+
86+
session.run(*args)
87+
88+
89+
@nox.session(py=DEFAULT_INTERPRETER)
90+
def lint(session):
91+
"""Run linters.
92+
Returns a failure if the linters find linting errors or sufficiently
93+
serious code quality issues.
94+
"""
95+
session.install("flake8", "black")
96+
run_black(session, use_check=True)
97+
session.run("flake8", "google", "tests")
98+
99+
71100
@nox.session(py=DEFAULT_INTERPRETER)
72101
def blacken(session):
73102
# Install all dependencies.
74103
session.install("black")
75104
# Run ``black``.
76-
session.run(
77-
"black",
78-
"--line-length=79",
79-
get_path("docs"),
80-
get_path("noxfile.py"),
81-
get_path("src"),
82-
get_path("tests"),
83-
)
105+
run_black(session)
84106

85107

86108
@nox.session(py=DEFAULT_INTERPRETER)

tests/unit/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ def test_compare_valid():
13701370
def test_compare_invalid():
13711371
prop = model.ModelKey()
13721372
with pytest.raises(exceptions.BadValueError):
1373-
prop == None
1373+
prop == None # noqa: E711
13741374

13751375
@staticmethod
13761376
def test__validate():

tests/unit/test_query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ class TestParameterizedThing:
5151
def test___eq__():
5252
thing = query.ParameterizedThing()
5353
with pytest.raises(NotImplementedError):
54-
thing == None
54+
thing == unittest.mock.sentinel.other
5555

5656
@staticmethod
5757
def test___ne__():
5858
thing = query.ParameterizedThing()
5959
with pytest.raises(NotImplementedError):
60-
thing != None
60+
thing != unittest.mock.sentinel.other
6161

6262

6363
class TestParameter:
@@ -143,12 +143,12 @@ def _make_one():
143143
def test___eq__(self):
144144
node = self._make_one()
145145
with pytest.raises(NotImplementedError):
146-
node == None
146+
node == unittest.mock.sentinel.other
147147

148148
def test___ne__(self):
149149
node = self._make_one()
150150
with pytest.raises(NotImplementedError):
151-
node != None
151+
node != unittest.mock.sentinel.other
152152

153153
def test___le__(self):
154154
node = self._make_one()

tests/unit/test_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import pytest
1818

1919
from google.cloud.ndb import utils
20-
import tests.unit.utils
2120

2221

2322
def test___all__():

0 commit comments

Comments
 (0)