|
16 | 16 | import nox |
17 | 17 |
|
18 | 18 | BLACK_VERSION = "black==22.3.0" |
| 19 | +ISORT_VERSION = "isort==5.11.0" |
19 | 20 | BLACK_PATHS = [ |
20 | 21 | "docs", |
21 | 22 | "django_spanner", |
|
25 | 26 | ] |
26 | 27 |
|
27 | 28 | MOCKSERVER_TEST_PYTHON_VERSION = "3.12" |
28 | | -DEFAULT_PYTHON_VERSION = "3.8" |
29 | | -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] |
30 | | -UNIT_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10"] |
| 29 | +DEFAULT_PYTHON_VERSION = "3.14" |
| 30 | + |
| 31 | +UNIT_TEST_PYTHON_VERSIONS = [ |
| 32 | + "3.8", |
| 33 | + "3.9", |
| 34 | + "3.10", |
| 35 | + "3.11", |
| 36 | + "3.12", |
| 37 | + "3.13", |
| 38 | + "3.14", |
| 39 | +] |
| 40 | +ALL_PYTHON = list(UNIT_TEST_PYTHON_VERSIONS) |
| 41 | +ALL_PYTHON.extend(["3.7"]) |
| 42 | + |
| 43 | +SYSTEM_TEST_PYTHON_VERSIONS = ALL_PYTHON |
31 | 44 |
|
32 | 45 | CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() |
33 | 46 |
|
@@ -61,7 +74,7 @@ def blacken(session): |
61 | 74 | @nox.session(python=DEFAULT_PYTHON_VERSION) |
62 | 75 | def lint_setup_py(session): |
63 | 76 | """Verify that setup.py is valid (including RST check).""" |
64 | | - session.install("docutils", "pygments") |
| 77 | + session.install("docutils", "pygments", "setuptools") |
65 | 78 | session.run( |
66 | 79 | "python", "setup.py", "check", "--restructuredtext", "--strict" |
67 | 80 | ) |
@@ -100,7 +113,7 @@ def default(session, django_version="3.2"): |
100 | 113 | ) |
101 | 114 |
|
102 | 115 |
|
103 | | -@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) |
| 116 | +@nox.session(python=ALL_PYTHON) |
104 | 117 | def unit(session): |
105 | 118 | """Run the unit test suite.""" |
106 | 119 | if session.python in ("3.7",): |
@@ -288,3 +301,44 @@ def docfx(session): |
288 | 301 | os.path.join("docs", ""), |
289 | 302 | os.path.join("docs", "_build", "html", ""), |
290 | 303 | ) |
| 304 | + |
| 305 | + |
| 306 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 307 | +def mypy(session): |
| 308 | + """Run the type checker.""" |
| 309 | + # TODO(https://github.com/googleapis/google-cloud-python/issues/16014): |
| 310 | + # Add mypy tests |
| 311 | + session.skip("mypy tests are not yet supported") |
| 312 | + |
| 313 | + |
| 314 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 315 | +def core_deps_from_source(session): |
| 316 | + """Run all tests with core dependencies installed from source |
| 317 | + rather than pulling the dependencies from PyPI. |
| 318 | + """ |
| 319 | + # TODO(https://github.com/googleapis/google-cloud-python/issues/16014): |
| 320 | + # Add core deps from source tests |
| 321 | + session.skip("Core deps from source tests are not yet supported") |
| 322 | + |
| 323 | + |
| 324 | +@nox.session(python=DEFAULT_PYTHON_VERSION) |
| 325 | +def prerelease_deps(session): |
| 326 | + """Run all tests with prerelease versions of dependencies installed.""" |
| 327 | + # TODO(https://github.com/googleapis/google-cloud-python/issues/16014): |
| 328 | + # Add prerelease deps tests |
| 329 | + session.skip("prerelease deps tests are not yet supported") |
| 330 | + |
| 331 | + |
| 332 | +@nox.session |
| 333 | +def format(session: nox.sessions.Session) -> None: |
| 334 | + """ |
| 335 | + Run isort to sort imports. Then run black |
| 336 | + to format code to uniform standard. |
| 337 | + """ |
| 338 | + session.install(BLACK_VERSION, ISORT_VERSION) |
| 339 | + python_files = [path for path in os.listdir(".") if path.endswith(".py")] |
| 340 | + |
| 341 | + # Use the --fss option to sort imports using strict alphabetical order. |
| 342 | + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections |
| 343 | + session.run("isort", "--fss", *python_files) |
| 344 | + session.run("black", *python_files) |
0 commit comments