We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
The release attrs==21.1.0 broke pytype check
Running the `pytype` check on `master` fails:
```
$ nox -s pytype
```

```
...
    return attr.evolve(self, *args, **kwargs)
  File "/home/peter/workspace/python-bigquery/.nox/pytype/lib/python3.8/site-packages/attr/_funcs.py", line 347, in evolve
    changes[init_name] = evolve(value, **changes[init_name])
TypeError: evolve() argument after ** must be a mapping, not NamedType
...
```

This happens with the most recent `attrs` release, namely [21.1.0](https://github.com/python-attrs/attrs/releases/tag/21.1.0). The error does not happen in a release before that ([attrs==20.3.0](https://github.com/python-attrs/attrs/releases/tag/20.3.0)).

A possible workaround is to temporarily force installing that version before running `pytype`.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `noxfile.py`
Content:
```
1 # Copyright 2016 Google LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 from __future__ import absolute_import
16 
17 import pathlib
18 import os
19 import shutil
20 
21 import nox
22 
23 
24 PYTYPE_VERSION = "pytype==2021.4.9"
25 BLACK_VERSION = "black==19.10b0"
26 BLACK_PATHS = ("docs", "google", "samples", "tests", "noxfile.py", "setup.py")
27 
28 DEFAULT_PYTHON_VERSION = "3.8"
29 SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"]
30 UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
31 CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
32 
33 # 'docfx' is excluded since it only needs to run in 'docs-presubmit'
34 nox.options.sessions = [
35     "unit_noextras",
36     "unit",
37     "system",
38     "snippets",
39     "cover",
40     "lint",
41     "lint_setup_py",
42     "blacken",
43     "pytype",
44     "docs",
45 ]
46 
47 
48 def default(session, install_extras=True):
49     """Default unit test session.
50 
51     This is intended to be run **without** an interpreter set, so
52     that the current ``python`` (on the ``PATH``) or the version of
53     Python corresponding to the ``nox`` binary the ``PATH`` can
54     run the tests.
55     """
56     constraints_path = str(
57         CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
58     )
59 
60     # Install all test dependencies, then install local packages in-place.
61     session.install(
62         "mock",
63         "pytest",
64         "google-cloud-testutils",
65         "pytest-cov",
66         "freezegun",
67         "-c",
68         constraints_path,
69     )
70 
71     install_target = ".[all]" if install_extras else "."
72     session.install("-e", install_target, "-c", constraints_path)
73 
74     session.install("ipython", "-c", constraints_path)
75 
76     # Run py.test against the unit tests.
77     session.run(
78         "py.test",
79         "--quiet",
80         "--cov=google/cloud/bigquery",
81         "--cov=tests/unit",
82         "--cov-append",
83         "--cov-config=.coveragerc",
84         "--cov-report=",
85         "--cov-fail-under=0",
86         os.path.join("tests", "unit"),
87         *session.posargs,
88     )
89 
90 
91 @nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
92 def unit(session):
93     """Run the unit test suite."""
94     default(session)
95 
96 
97 @nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])
98 def unit_noextras(session):
99     """Run the unit test suite."""
100     default(session, install_extras=False)
101 
102 
103 @nox.session(python=DEFAULT_PYTHON_VERSION)
104 def pytype(session):
105     """Run type checks."""
106     session.install("-e", ".[all]")
107     session.install("ipython")
108     session.install(PYTYPE_VERSION)
109     session.run("pytype")
110 
111 
112 @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
113 def system(session):
114     """Run the system test suite."""
115 
116     constraints_path = str(
117         CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
118     )
119 
120     # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
121     if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
122         session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
123 
124     # Sanity check: Only run system tests if the environment variable is set.
125     if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
126         session.skip("Credentials must be set via environment variable.")
127 
128     # Use pre-release gRPC for system tests.
129     session.install("--pre", "grpcio", "-c", constraints_path)
130 
131     # Install all test dependencies, then install local packages in place.
132     session.install(
133         "mock", "pytest", "psutil", "google-cloud-testutils", "-c", constraints_path
134     )
135     if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "") == "true":
136         # mTLS test requires pyopenssl and latest google-cloud-storage
137         session.install("google-cloud-storage", "pyopenssl")
138     else:
139         session.install("google-cloud-storage", "-c", constraints_path)
140 
141     session.install("-e", ".[all]", "-c", constraints_path)
142     session.install("ipython", "-c", constraints_path)
143 
144     # Run py.test against the system tests.
145     session.run("py.test", "--quiet", os.path.join("tests", "system"), *session.posargs)
146 
147 
148 @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
149 def snippets(session):
150     """Run the snippets test suite."""
151 
152     # Check the value of `RUN_SNIPPETS_TESTS` env var. It defaults to true.
153     if os.environ.get("RUN_SNIPPETS_TESTS", "true") == "false":
154         session.skip("RUN_SNIPPETS_TESTS is set to false, skipping")
155 
156     # Sanity check: Only run snippets tests if the environment variable is set.
157     if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
158         session.skip("Credentials must be set via environment variable.")
159 
160     constraints_path = str(
161         CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
162     )
163 
164     # Install all test dependencies, then install local packages in place.
165     session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path)
166     session.install("google-cloud-storage", "-c", constraints_path)
167     session.install("grpcio", "-c", constraints_path)
168 
169     session.install("-e", ".[all]", "-c", constraints_path)
170 
171     # Run py.test against the snippets tests.
172     # Skip tests in samples/snippets, as those are run in a different session
173     # using the nox config from that directory.
174     session.run("py.test", os.path.join("docs", "snippets.py"), *session.posargs)
175     session.run(
176         "py.test",
177         "samples",
178         "--ignore=samples/snippets",
179         "--ignore=samples/geography",
180         *session.posargs,
181     )
182 
183 
184 @nox.session(python=DEFAULT_PYTHON_VERSION)
185 def cover(session):
186     """Run the final coverage report.
187 
188     This outputs the coverage report aggregating coverage from the unit
189     test runs (not system test runs), and then erases coverage data.
190     """
191     session.install("coverage", "pytest-cov")
192     session.run("coverage", "report", "--show-missing", "--fail-under=100")
193     session.run("coverage", "erase")
194 
195 
196 @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
197 def prerelease_deps(session):
198     """Run all tests with prerelease versions of dependencies installed.
199 
200     https://github.com/googleapis/python-bigquery/issues/95
201     """
202     # PyArrow prerelease packages are published to an alternative PyPI host.
203     # https://arrow.apache.org/docs/python/install.html#installing-nightly-packages
204     session.install(
205         "--extra-index-url", "https://pypi.fury.io/arrow-nightlies/", "--pre", "pyarrow"
206     )
207     session.install("--pre", "grpcio", "pandas")
208     session.install(
209         "freezegun",
210         "google-cloud-storage",
211         "google-cloud-testutils",
212         "IPython",
213         "mock",
214         "psutil",
215         "pytest",
216         "pytest-cov",
217     )
218     session.install("-e", ".[all]")
219 
220     # Print out prerelease package versions.
221     session.run("python", "-c", "import grpc; print(grpc.__version__)")
222     session.run("python", "-c", "import pandas; print(pandas.__version__)")
223     session.run("python", "-c", "import pyarrow; print(pyarrow.__version__)")
224 
225     # Run all tests, except a few samples tests which require extra dependencies.
226     session.run("py.test", "tests/unit")
227     session.run("py.test", "tests/system")
228     session.run("py.test", "samples/tests")
229 
230 
231 @nox.session(python=DEFAULT_PYTHON_VERSION)
232 def lint(session):
233     """Run linters.
234 
235     Returns a failure if the linters find linting errors or sufficiently
236     serious code quality issues.
237     """
238 
239     session.install("flake8", BLACK_VERSION)
240     session.install("-e", ".")
241     session.run("flake8", os.path.join("google", "cloud", "bigquery"))
242     session.run("flake8", "tests")
243     session.run("flake8", os.path.join("docs", "samples"))
244     session.run("flake8", os.path.join("docs", "snippets.py"))
245     session.run("black", "--check", *BLACK_PATHS)
246 
247 
248 @nox.session(python=DEFAULT_PYTHON_VERSION)
249 def lint_setup_py(session):
250     """Verify that setup.py is valid (including RST check)."""
251 
252     session.install("docutils", "Pygments")
253     session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
254 
255 
256 @nox.session(python="3.6")
257 def blacken(session):
258     """Run black.
259     Format code to uniform standard.
260 
261     This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
262     That run uses an image that doesn't have 3.6 installed. Before updating this
263     check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
264     """
265     session.install(BLACK_VERSION)
266     session.run("black", *BLACK_PATHS)
267 
268 
269 @nox.session(python=DEFAULT_PYTHON_VERSION)
270 def docs(session):
271     """Build the docs."""
272 
273     session.install("ipython", "recommonmark", "sphinx", "sphinx_rtd_theme")
274     session.install("google-cloud-storage")
275     session.install("-e", ".[all]")
276 
277     shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
278     session.run(
279         "sphinx-build",
280         "-W",  # warnings as errors
281         "-T",  # show full traceback on exception
282         "-N",  # no colors
283         "-b",
284         "html",
285         "-d",
286         os.path.join("docs", "_build", "doctrees", ""),
287         os.path.join("docs", ""),
288         os.path.join("docs", "_build", "html", ""),
289     )
290 
291 
292 @nox.session(python=DEFAULT_PYTHON_VERSION)
293 def docfx(session):
294     """Build the docfx yaml files for this library."""
295 
296     session.install("-e", ".")
297     session.install("sphinx", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml")
298 
299     shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
300     session.run(
301         "sphinx-build",
302         "-T",  # show full traceback on exception
303         "-N",  # no colors
304         "-D",
305         (
306             "extensions=sphinx.ext.autodoc,"
307             "sphinx.ext.autosummary,"
308             "docfx_yaml.extension,"
309             "sphinx.ext.intersphinx,"
310             "sphinx.ext.coverage,"
311             "sphinx.ext.napoleon,"
312             "sphinx.ext.todo,"
313             "sphinx.ext.viewcode,"
314             "recommonmark"
315         ),
316         "-b",
317         "html",
318         "-d",
319         os.path.join("docs", "_build", "doctrees", ""),
320         os.path.join("docs", ""),
321         os.path.join("docs", "_build", "html", ""),
322     )
323
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -103,6 +103,10 @@
 @nox.session(python=DEFAULT_PYTHON_VERSION)
 def pytype(session):
     """Run type checks."""
+    # An indirect dependecy attrs==21.1.0 breaks the check, and installing a less
+    # recent version avoids the error until a possibly better fix is found.
+    # https://github.com/googleapis/python-bigquery/issues/655
+    session.install("attrs==20.3.0")
     session.install("-e", ".[all]")
     session.install("ipython")
     session.install(PYTYPE_VERSION)

{"golden_diff": "diff --git a/noxfile.py b/noxfile.py\n--- a/noxfile.py\n+++ b/noxfile.py\n@@ -103,6 +103,10 @@\n @nox.session(python=DEFAULT_PYTHON_VERSION)\n def pytype(session):\n     \"\"\"Run type checks.\"\"\"\n+    # An indirect dependecy attrs==21.1.0 breaks the check, and installing a less\n+    # recent version avoids the error until a possibly better fix is found.\n+    # https://github.com/googleapis/python-bigquery/issues/655\n+    session.install(\"attrs==20.3.0\")\n     session.install(\"-e\", \".[all]\")\n     session.install(\"ipython\")\n     session.install(PYTYPE_VERSION)\n", "issue": "The release attrs==21.1.0 broke pytype check\nRunning the `pytype` check on `master` fails:\r\n```\r\n$ nox -s pytype\r\n```\r\n\r\n```\r\n...\r\n    return attr.evolve(self, *args, **kwargs)\r\n  File \"/home/peter/workspace/python-bigquery/.nox/pytype/lib/python3.8/site-packages/attr/_funcs.py\", line 347, in evolve\r\n    changes[init_name] = evolve(value, **changes[init_name])\r\nTypeError: evolve() argument after ** must be a mapping, not NamedType\r\n...\r\n```\r\n\r\nThis happens with the most recent `attrs` release, namely [21.1.0](https://github.com/python-attrs/attrs/releases/tag/21.1.0). The error does not happen in a release before that ([attrs==20.3.0](https://github.com/python-attrs/attrs/releases/tag/20.3.0)).\r\n\r\nA possible workaround is to temporarily force installing that version before running `pytype`.\n", "before_files": [{"content": "# Copyright 2016 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom __future__ import absolute_import\n\nimport pathlib\nimport os\nimport shutil\n\nimport nox\n\n\nPYTYPE_VERSION = \"pytype==2021.4.9\"\nBLACK_VERSION = \"black==19.10b0\"\nBLACK_PATHS = (\"docs\", \"google\", \"samples\", \"tests\", \"noxfile.py\", \"setup.py\")\n\nDEFAULT_PYTHON_VERSION = \"3.8\"\nSYSTEM_TEST_PYTHON_VERSIONS = [\"3.8\"]\nUNIT_TEST_PYTHON_VERSIONS = [\"3.6\", \"3.7\", \"3.8\", \"3.9\"]\nCURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()\n\n# 'docfx' is excluded since it only needs to run in 'docs-presubmit'\nnox.options.sessions = [\n    \"unit_noextras\",\n    \"unit\",\n    \"system\",\n    \"snippets\",\n    \"cover\",\n    \"lint\",\n    \"lint_setup_py\",\n    \"blacken\",\n    \"pytype\",\n    \"docs\",\n]\n\n\ndef default(session, install_extras=True):\n    \"\"\"Default unit test session.\n\n    This is intended to be run **without** an interpreter set, so\n    that the current ``python`` (on the ``PATH``) or the version of\n    Python corresponding to the ``nox`` binary the ``PATH`` can\n    run the tests.\n    \"\"\"\n    constraints_path = str(\n        CURRENT_DIRECTORY / \"testing\" / f\"constraints-{session.python}.txt\"\n    )\n\n    # Install all test dependencies, then install local packages in-place.\n    session.install(\n        \"mock\",\n        \"pytest\",\n        \"google-cloud-testutils\",\n        \"pytest-cov\",\n        \"freezegun\",\n        \"-c\",\n        constraints_path,\n    )\n\n    install_target = \".[all]\" if install_extras else \".\"\n    session.install(\"-e\", install_target, \"-c\", constraints_path)\n\n    session.install(\"ipython\", \"-c\", constraints_path)\n\n    # Run py.test against the unit tests.\n    session.run(\n        \"py.test\",\n        \"--quiet\",\n        \"--cov=google/cloud/bigquery\",\n        \"--cov=tests/unit\",\n        \"--cov-append\",\n        \"--cov-config=.coveragerc\",\n        \"--cov-report=\",\n        \"--cov-fail-under=0\",\n        os.path.join(\"tests\", \"unit\"),\n        *session.posargs,\n    )\n\n\n@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)\ndef unit(session):\n    \"\"\"Run the unit test suite.\"\"\"\n    default(session)\n\n\n@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])\ndef unit_noextras(session):\n    \"\"\"Run the unit test suite.\"\"\"\n    default(session, install_extras=False)\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef pytype(session):\n    \"\"\"Run type checks.\"\"\"\n    session.install(\"-e\", \".[all]\")\n    session.install(\"ipython\")\n    session.install(PYTYPE_VERSION)\n    session.run(\"pytype\")\n\n\n@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)\ndef system(session):\n    \"\"\"Run the system test suite.\"\"\"\n\n    constraints_path = str(\n        CURRENT_DIRECTORY / \"testing\" / f\"constraints-{session.python}.txt\"\n    )\n\n    # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.\n    if os.environ.get(\"RUN_SYSTEM_TESTS\", \"true\") == \"false\":\n        session.skip(\"RUN_SYSTEM_TESTS is set to false, skipping\")\n\n    # Sanity check: Only run system tests if the environment variable is set.\n    if not os.environ.get(\"GOOGLE_APPLICATION_CREDENTIALS\", \"\"):\n        session.skip(\"Credentials must be set via environment variable.\")\n\n    # Use pre-release gRPC for system tests.\n    session.install(\"--pre\", \"grpcio\", \"-c\", constraints_path)\n\n    # Install all test dependencies, then install local packages in place.\n    session.install(\n        \"mock\", \"pytest\", \"psutil\", \"google-cloud-testutils\", \"-c\", constraints_path\n    )\n    if os.environ.get(\"GOOGLE_API_USE_CLIENT_CERTIFICATE\", \"\") == \"true\":\n        # mTLS test requires pyopenssl and latest google-cloud-storage\n        session.install(\"google-cloud-storage\", \"pyopenssl\")\n    else:\n        session.install(\"google-cloud-storage\", \"-c\", constraints_path)\n\n    session.install(\"-e\", \".[all]\", \"-c\", constraints_path)\n    session.install(\"ipython\", \"-c\", constraints_path)\n\n    # Run py.test against the system tests.\n    session.run(\"py.test\", \"--quiet\", os.path.join(\"tests\", \"system\"), *session.posargs)\n\n\n@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)\ndef snippets(session):\n    \"\"\"Run the snippets test suite.\"\"\"\n\n    # Check the value of `RUN_SNIPPETS_TESTS` env var. It defaults to true.\n    if os.environ.get(\"RUN_SNIPPETS_TESTS\", \"true\") == \"false\":\n        session.skip(\"RUN_SNIPPETS_TESTS is set to false, skipping\")\n\n    # Sanity check: Only run snippets tests if the environment variable is set.\n    if not os.environ.get(\"GOOGLE_APPLICATION_CREDENTIALS\", \"\"):\n        session.skip(\"Credentials must be set via environment variable.\")\n\n    constraints_path = str(\n        CURRENT_DIRECTORY / \"testing\" / f\"constraints-{session.python}.txt\"\n    )\n\n    # Install all test dependencies, then install local packages in place.\n    session.install(\"mock\", \"pytest\", \"google-cloud-testutils\", \"-c\", constraints_path)\n    session.install(\"google-cloud-storage\", \"-c\", constraints_path)\n    session.install(\"grpcio\", \"-c\", constraints_path)\n\n    session.install(\"-e\", \".[all]\", \"-c\", constraints_path)\n\n    # Run py.test against the snippets tests.\n    # Skip tests in samples/snippets, as those are run in a different session\n    # using the nox config from that directory.\n    session.run(\"py.test\", os.path.join(\"docs\", \"snippets.py\"), *session.posargs)\n    session.run(\n        \"py.test\",\n        \"samples\",\n        \"--ignore=samples/snippets\",\n        \"--ignore=samples/geography\",\n        *session.posargs,\n    )\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef cover(session):\n    \"\"\"Run the final coverage report.\n\n    This outputs the coverage report aggregating coverage from the unit\n    test runs (not system test runs), and then erases coverage data.\n    \"\"\"\n    session.install(\"coverage\", \"pytest-cov\")\n    session.run(\"coverage\", \"report\", \"--show-missing\", \"--fail-under=100\")\n    session.run(\"coverage\", \"erase\")\n\n\n@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)\ndef prerelease_deps(session):\n    \"\"\"Run all tests with prerelease versions of dependencies installed.\n\n    https://github.com/googleapis/python-bigquery/issues/95\n    \"\"\"\n    # PyArrow prerelease packages are published to an alternative PyPI host.\n    # https://arrow.apache.org/docs/python/install.html#installing-nightly-packages\n    session.install(\n        \"--extra-index-url\", \"https://pypi.fury.io/arrow-nightlies/\", \"--pre\", \"pyarrow\"\n    )\n    session.install(\"--pre\", \"grpcio\", \"pandas\")\n    session.install(\n        \"freezegun\",\n        \"google-cloud-storage\",\n        \"google-cloud-testutils\",\n        \"IPython\",\n        \"mock\",\n        \"psutil\",\n        \"pytest\",\n        \"pytest-cov\",\n    )\n    session.install(\"-e\", \".[all]\")\n\n    # Print out prerelease package versions.\n    session.run(\"python\", \"-c\", \"import grpc; print(grpc.__version__)\")\n    session.run(\"python\", \"-c\", \"import pandas; print(pandas.__version__)\")\n    session.run(\"python\", \"-c\", \"import pyarrow; print(pyarrow.__version__)\")\n\n    # Run all tests, except a few samples tests which require extra dependencies.\n    session.run(\"py.test\", \"tests/unit\")\n    session.run(\"py.test\", \"tests/system\")\n    session.run(\"py.test\", \"samples/tests\")\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef lint(session):\n    \"\"\"Run linters.\n\n    Returns a failure if the linters find linting errors or sufficiently\n    serious code quality issues.\n    \"\"\"\n\n    session.install(\"flake8\", BLACK_VERSION)\n    session.install(\"-e\", \".\")\n    session.run(\"flake8\", os.path.join(\"google\", \"cloud\", \"bigquery\"))\n    session.run(\"flake8\", \"tests\")\n    session.run(\"flake8\", os.path.join(\"docs\", \"samples\"))\n    session.run(\"flake8\", os.path.join(\"docs\", \"snippets.py\"))\n    session.run(\"black\", \"--check\", *BLACK_PATHS)\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef lint_setup_py(session):\n    \"\"\"Verify that setup.py is valid (including RST check).\"\"\"\n\n    session.install(\"docutils\", \"Pygments\")\n    session.run(\"python\", \"setup.py\", \"check\", \"--restructuredtext\", \"--strict\")\n\n\n@nox.session(python=\"3.6\")\ndef blacken(session):\n    \"\"\"Run black.\n    Format code to uniform standard.\n\n    This currently uses Python 3.6 due to the automated Kokoro run of synthtool.\n    That run uses an image that doesn't have 3.6 installed. Before updating this\n    check the state of the `gcp_ubuntu_config` we use for that Kokoro run.\n    \"\"\"\n    session.install(BLACK_VERSION)\n    session.run(\"black\", *BLACK_PATHS)\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef docs(session):\n    \"\"\"Build the docs.\"\"\"\n\n    session.install(\"ipython\", \"recommonmark\", \"sphinx\", \"sphinx_rtd_theme\")\n    session.install(\"google-cloud-storage\")\n    session.install(\"-e\", \".[all]\")\n\n    shutil.rmtree(os.path.join(\"docs\", \"_build\"), ignore_errors=True)\n    session.run(\n        \"sphinx-build\",\n        \"-W\",  # warnings as errors\n        \"-T\",  # show full traceback on exception\n        \"-N\",  # no colors\n        \"-b\",\n        \"html\",\n        \"-d\",\n        os.path.join(\"docs\", \"_build\", \"doctrees\", \"\"),\n        os.path.join(\"docs\", \"\"),\n        os.path.join(\"docs\", \"_build\", \"html\", \"\"),\n    )\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef docfx(session):\n    \"\"\"Build the docfx yaml files for this library.\"\"\"\n\n    session.install(\"-e\", \".\")\n    session.install(\"sphinx\", \"alabaster\", \"recommonmark\", \"gcp-sphinx-docfx-yaml\")\n\n    shutil.rmtree(os.path.join(\"docs\", \"_build\"), ignore_errors=True)\n    session.run(\n        \"sphinx-build\",\n        \"-T\",  # show full traceback on exception\n        \"-N\",  # no colors\n        \"-D\",\n        (\n            \"extensions=sphinx.ext.autodoc,\"\n            \"sphinx.ext.autosummary,\"\n            \"docfx_yaml.extension,\"\n            \"sphinx.ext.intersphinx,\"\n            \"sphinx.ext.coverage,\"\n            \"sphinx.ext.napoleon,\"\n            \"sphinx.ext.todo,\"\n            \"sphinx.ext.viewcode,\"\n            \"recommonmark\"\n        ),\n        \"-b\",\n        \"html\",\n        \"-d\",\n        os.path.join(\"docs\", \"_build\", \"doctrees\", \"\"),\n        os.path.join(\"docs\", \"\"),\n        os.path.join(\"docs\", \"_build\", \"html\", \"\"),\n    )\n", "path": "noxfile.py"}], "after_files": [{"content": "# Copyright 2016 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom __future__ import absolute_import\n\nimport pathlib\nimport os\nimport shutil\n\nimport nox\n\n\nPYTYPE_VERSION = \"pytype==2021.4.9\"\nBLACK_VERSION = \"black==19.10b0\"\nBLACK_PATHS = (\"docs\", \"google\", \"samples\", \"tests\", \"noxfile.py\", \"setup.py\")\n\nDEFAULT_PYTHON_VERSION = \"3.8\"\nSYSTEM_TEST_PYTHON_VERSIONS = [\"3.8\"]\nUNIT_TEST_PYTHON_VERSIONS = [\"3.6\", \"3.7\", \"3.8\", \"3.9\"]\nCURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()\n\n# 'docfx' is excluded since it only needs to run in 'docs-presubmit'\nnox.options.sessions = [\n    \"unit_noextras\",\n    \"unit\",\n    \"system\",\n    \"snippets\",\n    \"cover\",\n    \"lint\",\n    \"lint_setup_py\",\n    \"blacken\",\n    \"pytype\",\n    \"docs\",\n]\n\n\ndef default(session, install_extras=True):\n    \"\"\"Default unit test session.\n\n    This is intended to be run **without** an interpreter set, so\n    that the current ``python`` (on the ``PATH``) or the version of\n    Python corresponding to the ``nox`` binary the ``PATH`` can\n    run the tests.\n    \"\"\"\n    constraints_path = str(\n        CURRENT_DIRECTORY / \"testing\" / f\"constraints-{session.python}.txt\"\n    )\n\n    # Install all test dependencies, then install local packages in-place.\n    session.install(\n        \"mock\",\n        \"pytest\",\n        \"google-cloud-testutils\",\n        \"pytest-cov\",\n        \"freezegun\",\n        \"-c\",\n        constraints_path,\n    )\n\n    install_target = \".[all]\" if install_extras else \".\"\n    session.install(\"-e\", install_target, \"-c\", constraints_path)\n\n    session.install(\"ipython\", \"-c\", constraints_path)\n\n    # Run py.test against the unit tests.\n    session.run(\n        \"py.test\",\n        \"--quiet\",\n        \"--cov=google/cloud/bigquery\",\n        \"--cov=tests/unit\",\n        \"--cov-append\",\n        \"--cov-config=.coveragerc\",\n        \"--cov-report=\",\n        \"--cov-fail-under=0\",\n        os.path.join(\"tests\", \"unit\"),\n        *session.posargs,\n    )\n\n\n@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)\ndef unit(session):\n    \"\"\"Run the unit test suite.\"\"\"\n    default(session)\n\n\n@nox.session(python=UNIT_TEST_PYTHON_VERSIONS[-1])\ndef unit_noextras(session):\n    \"\"\"Run the unit test suite.\"\"\"\n    default(session, install_extras=False)\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef pytype(session):\n    \"\"\"Run type checks.\"\"\"\n    # An indirect dependecy attrs==21.1.0 breaks the check, and installing a less\n    # recent version avoids the error until a possibly better fix is found.\n    # https://github.com/googleapis/python-bigquery/issues/655\n    session.install(\"attrs==20.3.0\")\n    session.install(\"-e\", \".[all]\")\n    session.install(\"ipython\")\n    session.install(PYTYPE_VERSION)\n    session.run(\"pytype\")\n\n\n@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)\ndef system(session):\n    \"\"\"Run the system test suite.\"\"\"\n\n    constraints_path = str(\n        CURRENT_DIRECTORY / \"testing\" / f\"constraints-{session.python}.txt\"\n    )\n\n    # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.\n    if os.environ.get(\"RUN_SYSTEM_TESTS\", \"true\") == \"false\":\n        session.skip(\"RUN_SYSTEM_TESTS is set to false, skipping\")\n\n    # Sanity check: Only run system tests if the environment variable is set.\n    if not os.environ.get(\"GOOGLE_APPLICATION_CREDENTIALS\", \"\"):\n        session.skip(\"Credentials must be set via environment variable.\")\n\n    # Use pre-release gRPC for system tests.\n    session.install(\"--pre\", \"grpcio\", \"-c\", constraints_path)\n\n    # Install all test dependencies, then install local packages in place.\n    session.install(\n        \"mock\", \"pytest\", \"psutil\", \"google-cloud-testutils\", \"-c\", constraints_path\n    )\n    if os.environ.get(\"GOOGLE_API_USE_CLIENT_CERTIFICATE\", \"\") == \"true\":\n        # mTLS test requires pyopenssl and latest google-cloud-storage\n        session.install(\"google-cloud-storage\", \"pyopenssl\")\n    else:\n        session.install(\"google-cloud-storage\", \"-c\", constraints_path)\n\n    session.install(\"-e\", \".[all]\", \"-c\", constraints_path)\n    session.install(\"ipython\", \"-c\", constraints_path)\n\n    # Run py.test against the system tests.\n    session.run(\"py.test\", \"--quiet\", os.path.join(\"tests\", \"system\"), *session.posargs)\n\n\n@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)\ndef snippets(session):\n    \"\"\"Run the snippets test suite.\"\"\"\n\n    # Check the value of `RUN_SNIPPETS_TESTS` env var. It defaults to true.\n    if os.environ.get(\"RUN_SNIPPETS_TESTS\", \"true\") == \"false\":\n        session.skip(\"RUN_SNIPPETS_TESTS is set to false, skipping\")\n\n    # Sanity check: Only run snippets tests if the environment variable is set.\n    if not os.environ.get(\"GOOGLE_APPLICATION_CREDENTIALS\", \"\"):\n        session.skip(\"Credentials must be set via environment variable.\")\n\n    constraints_path = str(\n        CURRENT_DIRECTORY / \"testing\" / f\"constraints-{session.python}.txt\"\n    )\n\n    # Install all test dependencies, then install local packages in place.\n    session.install(\"mock\", \"pytest\", \"google-cloud-testutils\", \"-c\", constraints_path)\n    session.install(\"google-cloud-storage\", \"-c\", constraints_path)\n    session.install(\"grpcio\", \"-c\", constraints_path)\n\n    session.install(\"-e\", \".[all]\", \"-c\", constraints_path)\n\n    # Run py.test against the snippets tests.\n    # Skip tests in samples/snippets, as those are run in a different session\n    # using the nox config from that directory.\n    session.run(\"py.test\", os.path.join(\"docs\", \"snippets.py\"), *session.posargs)\n    session.run(\n        \"py.test\",\n        \"samples\",\n        \"--ignore=samples/snippets\",\n        \"--ignore=samples/geography\",\n        *session.posargs,\n    )\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef cover(session):\n    \"\"\"Run the final coverage report.\n\n    This outputs the coverage report aggregating coverage from the unit\n    test runs (not system test runs), and then erases coverage data.\n    \"\"\"\n    session.install(\"coverage\", \"pytest-cov\")\n    session.run(\"coverage\", \"report\", \"--show-missing\", \"--fail-under=100\")\n    session.run(\"coverage\", \"erase\")\n\n\n@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)\ndef prerelease_deps(session):\n    \"\"\"Run all tests with prerelease versions of dependencies installed.\n\n    https://github.com/googleapis/python-bigquery/issues/95\n    \"\"\"\n    # PyArrow prerelease packages are published to an alternative PyPI host.\n    # https://arrow.apache.org/docs/python/install.html#installing-nightly-packages\n    session.install(\n        \"--extra-index-url\", \"https://pypi.fury.io/arrow-nightlies/\", \"--pre\", \"pyarrow\"\n    )\n    session.install(\"--pre\", \"grpcio\", \"pandas\")\n    session.install(\n        \"freezegun\",\n        \"google-cloud-storage\",\n        \"google-cloud-testutils\",\n        \"IPython\",\n        \"mock\",\n        \"psutil\",\n        \"pytest\",\n        \"pytest-cov\",\n    )\n    session.install(\"-e\", \".[all]\")\n\n    # Print out prerelease package versions.\n    session.run(\"python\", \"-c\", \"import grpc; print(grpc.__version__)\")\n    session.run(\"python\", \"-c\", \"import pandas; print(pandas.__version__)\")\n    session.run(\"python\", \"-c\", \"import pyarrow; print(pyarrow.__version__)\")\n\n    # Run all tests, except a few samples tests which require extra dependencies.\n    session.run(\"py.test\", \"tests/unit\")\n    session.run(\"py.test\", \"tests/system\")\n    session.run(\"py.test\", \"samples/tests\")\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef lint(session):\n    \"\"\"Run linters.\n\n    Returns a failure if the linters find linting errors or sufficiently\n    serious code quality issues.\n    \"\"\"\n\n    session.install(\"flake8\", BLACK_VERSION)\n    session.install(\"-e\", \".\")\n    session.run(\"flake8\", os.path.join(\"google\", \"cloud\", \"bigquery\"))\n    session.run(\"flake8\", \"tests\")\n    session.run(\"flake8\", os.path.join(\"docs\", \"samples\"))\n    session.run(\"flake8\", os.path.join(\"docs\", \"snippets.py\"))\n    session.run(\"black\", \"--check\", *BLACK_PATHS)\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef lint_setup_py(session):\n    \"\"\"Verify that setup.py is valid (including RST check).\"\"\"\n\n    session.install(\"docutils\", \"Pygments\")\n    session.run(\"python\", \"setup.py\", \"check\", \"--restructuredtext\", \"--strict\")\n\n\n@nox.session(python=\"3.6\")\ndef blacken(session):\n    \"\"\"Run black.\n    Format code to uniform standard.\n\n    This currently uses Python 3.6 due to the automated Kokoro run of synthtool.\n    That run uses an image that doesn't have 3.6 installed. Before updating this\n    check the state of the `gcp_ubuntu_config` we use for that Kokoro run.\n    \"\"\"\n    session.install(BLACK_VERSION)\n    session.run(\"black\", *BLACK_PATHS)\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef docs(session):\n    \"\"\"Build the docs.\"\"\"\n\n    session.install(\"ipython\", \"recommonmark\", \"sphinx\", \"sphinx_rtd_theme\")\n    session.install(\"google-cloud-storage\")\n    session.install(\"-e\", \".[all]\")\n\n    shutil.rmtree(os.path.join(\"docs\", \"_build\"), ignore_errors=True)\n    session.run(\n        \"sphinx-build\",\n        \"-W\",  # warnings as errors\n        \"-T\",  # show full traceback on exception\n        \"-N\",  # no colors\n        \"-b\",\n        \"html\",\n        \"-d\",\n        os.path.join(\"docs\", \"_build\", \"doctrees\", \"\"),\n        os.path.join(\"docs\", \"\"),\n        os.path.join(\"docs\", \"_build\", \"html\", \"\"),\n    )\n\n\n@nox.session(python=DEFAULT_PYTHON_VERSION)\ndef docfx(session):\n    \"\"\"Build the docfx yaml files for this library.\"\"\"\n\n    session.install(\"-e\", \".\")\n    session.install(\"sphinx\", \"alabaster\", \"recommonmark\", \"gcp-sphinx-docfx-yaml\")\n\n    shutil.rmtree(os.path.join(\"docs\", \"_build\"), ignore_errors=True)\n    session.run(\n        \"sphinx-build\",\n        \"-T\",  # show full traceback on exception\n        \"-N\",  # no colors\n        \"-D\",\n        (\n            \"extensions=sphinx.ext.autodoc,\"\n            \"sphinx.ext.autosummary,\"\n            \"docfx_yaml.extension,\"\n            \"sphinx.ext.intersphinx,\"\n            \"sphinx.ext.coverage,\"\n            \"sphinx.ext.napoleon,\"\n            \"sphinx.ext.todo,\"\n            \"sphinx.ext.viewcode,\"\n            \"recommonmark\"\n        ),\n        \"-b\",\n        \"html\",\n        \"-d\",\n        os.path.join(\"docs\", \"_build\", \"doctrees\", \"\"),\n        os.path.join(\"docs\", \"\"),\n        os.path.join(\"docs\", \"_build\", \"html\", \"\"),\n    )\n", "path": "noxfile.py"}]}