1818import pathlib
1919
2020
21+ BLACK_VERSION = "black[jupyter]==23.7.0"
22+ ISORT_VERSION = "isort==5.11.0"
23+
24+ LINT_PATHS = ["docs" , "proto" , "tests" , "noxfile.py" , "setup.py" ]
25+
2126CURRENT_DIRECTORY = pathlib .Path (__file__ ).parent .absolute ()
2227
23- DEFAULT_PYTHON_VERSION = "3.14"
28+ DEFAULT_PYTHON_VERSION = "3.14"
2429
2530PYTHON_VERSIONS = [
2631 "3.7" ,
4247def unit (session , implementation ):
4348 """Run the unit test suite."""
4449
50+ # TODO(https://github.com/googleapis/gapic-generator-python/issues/2388):
51+ # Remove this check once support for Protobuf 3.x is dropped.
52+ if implementation == "cpp" and session .python in (
53+ "3.11" ,
54+ "3.12" ,
55+ "3.13" ,
56+ "3.14" ,
57+ ):
58+ session .skip ("cpp implementation is not supported in python 3.11+" )
59+
4560 constraints_path = str (
4661 CURRENT_DIRECTORY / "testing" / f"constraints-{ session .python } .txt"
4762 )
@@ -178,4 +193,21 @@ def mypy(session):
178193
179194 # TODO(https://github.com/googleapis/google-cloud-python/issues/15104):
180195 # Enable mypy once this bug is fixed.
181- session .skip ("Skip mypy since this library doesn't have py.typed" )
196+ session .skip ("Skip mypy since this library doesn't have py.typed" )
197+
198+
199+ @nox .session (python = DEFAULT_PYTHON_VERSION )
200+ def lint (session ):
201+ """Run linters.
202+
203+ Returns a failure if the linters find linting errors or sufficiently
204+ serious code quality issues.
205+ """
206+ session .install ("flake8" , BLACK_VERSION )
207+ session .run (
208+ "black" ,
209+ "--check" ,
210+ * LINT_PATHS ,
211+ )
212+
213+ session .run ("flake8" , "proto" , "tests" )
0 commit comments