Skip to content

Commit fb7de39

Browse files
chalmerlowegcf-owl-bot[bot]tswast
authored
deps: Remove Python 3.7 and 3.8 as supported runtimes (#2133)
* Initial batch of changes to remove 3.7 and 3.8 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * more updates to remove 3.7 and 3.8 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * updates samples/geography/reqs * updates samples/magics/reqs * updates samples/notebooks/reqs * updates linting * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * updates conf due to linting issue * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * updates reqs.txt, fix mypy, lint, and debug in noxfile * Updates owlbot to correct spacing issue in conf.py * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * updates owlbot imports * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * removes kokoro samples configs for 3.7 & 3.8 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * removes owlbots attempt to restore kokoro samples configs * removes kokoro system-3.8.cfg * edits repo sync settings * updates assorted noxfiles for samples and pyproject.toml * update test-samples-impl.sh * updates install_deps template * Edits to the contributing documentation * deps: use pandas-gbq to determine schema in `load_table_from_dataframe` (#2095) * feat: use pandas-gbq to determine schema in `load_table_from_dataframe` * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix some unit tests * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * bump minimum pandas-gbq to 0.26.1 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * drop pandas-gbq from python 3.7 extras * relax warning message text assertion * use consistent time zone presense/absense in time datetime system test * Update google/cloud/bigquery/_pandas_helpers.py * Update google/cloud/bigquery/_pandas_helpers.py Co-authored-by: Chalmer Lowe <[email protected]> * remove pandas-gbq from at least 1 unit test and system test session --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Chalmer Lowe <[email protected]> * Feat: Adds foreign_type_info attribute to table class and adds unit tests. (#2126) * adds foreign_type_info attribute to table * feat: Adds foreign_type_info attribute and tests * updates docstrings for foreign_type_info * Updates property handling, especially as regards set/get_sub_prop * Removes extraneous comments and debug expressions * Refactors build_resource_from_properties w get/set_sub_prop * updates to foreign_type_info, tests and wiring * Adds logic to detect non-Sequence schema.fields value * updates assorted tests and logic * deps: updates required checks list in github (#2136) * deps: updates required checks list in github * deps: updates snippet and system checks in github to remove 3.9 * changes the order of two items in the list. * updates linting * reverts pandas back to 1.1.0 * Revert changes related to pandas <1.5 * Revert noxfile.py changes related to pandas <1.5 * Revert constraints-3.9 changes related to pandas <1.5 * Revert test_query_pandas.py changes related to pandas <1.5 * Revert test__pandas_helpers.py changes related to pandas <1.5 * Revert test__versions_helpers.py changes related to pandas <1.5 * Revert tnoxfile.py changes related to pandas <1.5 * Revert test__versions_helpers.py changes related to pandas <1.5 * Revert test_table.py changes related to pandas <1.5 * Update noxfile changes related to pandas <1.5 * Update pyproject.toml changes related to pandas <1.5 * Update constraints-3.9.txt changes related to pandas <1.5 * Update test_legacy_types.py changes related to pandas <1.5 * Updates magics.py as part of reverting from pandas 1.5 * Updates noxfile.py in reverting from pandas 1.5 * Updates pyproject.toml in reverting from pandas 1.5 * Updates constraints.txt in reverting from pandas 1.5 * Updates test_magics in reverting from pandas 1.5 * Updates test_table in reverting from pandas 1.5 * Updates in tests re: reverting from pandas 1.5 * Updates pyproject to match constraints.txt * updates pyproject.toml to mirror constraints * remove limit on virtualenv * updates owlbot.py for test-samples-impl.sh * updates to owlbot.py * updates to test-samples-impl.sh * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * further updates to owlbot.py * removes unneeded files * adds presubmit.cfg back in --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Tim Sweña (Swast) <[email protected]>
1 parent 3a1e3f3 commit fb7de39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+274
-377
lines changed

.coveragerc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ omit =
99
google/cloud/bigquery_v2/* # Legacy proto-based types.
1010
exclude_lines =
1111
# Re-enable the standard pragma
12-
pragma: NO COVER
12+
pragma: (no cover|NO COVER)
1313
# Ignore debug-only repr
1414
def __repr__

.kokoro/presubmit/snippets-3.8.cfg .kokoro/presubmit/snippets-3.9.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Only run this nox session.
44
env_vars: {
55
key: "NOX_SESSION"
6-
value: "snippets-3.8"
6+
value: "snippets-3.9"
77
}

.kokoro/presubmit/system-3.8.cfg .kokoro/presubmit/system-3.9.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Only run this nox session.
44
env_vars: {
55
key: "NOX_SESSION"
6-
value: "system-3.8"
7-
}
6+
value: "system-3.9"
7+
}

.kokoro/samples/python3.7/common.cfg

-40
This file was deleted.

.kokoro/samples/python3.7/continuous.cfg

-6
This file was deleted.

.kokoro/samples/python3.7/periodic-head.cfg

-11
This file was deleted.

.kokoro/samples/python3.7/periodic.cfg

-6
This file was deleted.

.kokoro/samples/python3.7/presubmit.cfg

-6
This file was deleted.

.kokoro/samples/python3.8/common.cfg

-40
This file was deleted.

.kokoro/samples/python3.8/continuous.cfg

-6
This file was deleted.

.kokoro/samples/python3.8/periodic-head.cfg

-11
This file was deleted.

.kokoro/samples/python3.8/periodic.cfg

-6
This file was deleted.

.kokoro/samples/python3.8/presubmit.cfg

-6
This file was deleted.

.kokoro/test-samples-impl.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ export PYTHONUNBUFFERED=1
3333
env | grep KOKORO
3434

3535
# Install nox
36-
# `virtualenv==20.26.6` is added for Python 3.7 compatibility
37-
python3.9 -m pip install --upgrade --quiet nox virtualenv==20.26.6
36+
python3.9 -m pip install --upgrade --quiet nox virtualenv
3837

3938
# Use secrets acessor service account to get secrets
4039
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then

CONTRIBUTING.rst

+5-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In order to add a feature:
2222
documentation.
2323

2424
- The feature must work fully on the following CPython versions:
25-
3.7, 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13 on both UNIX and Windows.
25+
3.9, 3.10, 3.11, 3.12 and 3.13 on both UNIX and Windows.
2626

2727
- The feature must not add unnecessary dependencies (where
2828
"unnecessary" is of course subjective, but new dependencies should
@@ -143,13 +143,12 @@ Running System Tests
143143
$ nox -s system
144144

145145
# Run a single system test
146-
$ nox -s system-3.8 -- -k <name of test>
146+
$ nox -s system-3.9 -- -k <name of test>
147147

148148

149149
.. note::
150150

151-
System tests are only configured to run under Python 3.8.
152-
For expediency, we do not run them in older versions of Python 3.
151+
System tests are configured to run under Python 3.9, 3.11, 3.12.
153152

154153
This alone will not run the tests. You'll need to change some local
155154
auth settings and change some configuration in your project to
@@ -195,11 +194,11 @@ configure them just like the System Tests.
195194

196195
# Run all tests in a folder
197196
$ cd samples/snippets
198-
$ nox -s py-3.8
197+
$ nox -s py-3.9
199198

200199
# Run a single sample test
201200
$ cd samples/snippets
202-
$ nox -s py-3.8 -- -k <name of test>
201+
$ nox -s py-3.9 -- -k <name of test>
203202

204203
********************************************
205204
Note About ``README`` as it pertains to PyPI
@@ -221,16 +220,12 @@ Supported Python Versions
221220

222221
We support:
223222

224-
- `Python 3.7`_
225-
- `Python 3.8`_
226223
- `Python 3.9`_
227224
- `Python 3.10`_
228225
- `Python 3.11`_
229226
- `Python 3.12`_
230227
- `Python 3.13`_
231228

232-
.. _Python 3.7: https://docs.python.org/3.7/
233-
.. _Python 3.8: https://docs.python.org/3.8/
234229
.. _Python 3.9: https://docs.python.org/3.9/
235230
.. _Python 3.10: https://docs.python.org/3.10/
236231
.. _Python 3.11: https://docs.python.org/3.11/

README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ dependencies.
5252

5353
Supported Python Versions
5454
^^^^^^^^^^^^^^^^^^^^^^^^^
55-
Python >= 3.7
55+
Python >= 3.9
5656

5757
Unsupported Python Versions
5858
^^^^^^^^^^^^^^^^^^^^^^^^^^^
59-
Python == 2.7, Python == 3.5, Python == 3.6.
59+
Python == 2.7, Python == 3.5, Python == 3.6, Python == 3.7, and Python == 3.8.
6060

6161
The last version of this library compatible with Python 2.7 and 3.5 is
6262
`google-cloud-bigquery==1.28.0`.

google/cloud/bigquery/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@
126126

127127
if sys_major == 3 and sys_minor in (7, 8):
128128
warnings.warn(
129-
"The python-bigquery library will stop supporting Python 3.7 "
130-
"and Python 3.8 in a future major release expected in Q4 2024. "
129+
"The python-bigquery library no longer supports Python 3.7 "
130+
"and Python 3.8. "
131131
f"Your Python version is {sys_major}.{sys_minor}.{sys_micro}. We "
132132
"recommend that you update soon to ensure ongoing support. For "
133133
"more details, see: [Google Cloud Client Libraries Supported Python Versions policy](https://cloud.google.com/python/docs/supported-python-versions)",
134-
PendingDeprecationWarning,
134+
FutureWarning,
135135
)
136136

137137
__all__ = [

google/cloud/bigquery/_pandas_helpers.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,13 @@ def types_mapper(arrow_data_type):
336336
):
337337
return range_date_dtype
338338

339-
elif range_timestamp_dtype is not None and arrow_data_type.equals(
340-
range_timestamp_dtype.pyarrow_dtype
339+
# TODO: this section does not have a test yet OR at least not one that is
340+
# recognized by coverage, hence the pragma. See Issue: #2132
341+
elif (
342+
range_timestamp_dtype is not None
343+
and arrow_data_type.equals( # pragma: NO COVER
344+
range_timestamp_dtype.pyarrow_dtype
345+
)
341346
):
342347
return range_timestamp_dtype
343348

google/cloud/bigquery/_pyarrow_helpers.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
from typing import Any
2323

24-
from packaging import version
25-
2624
try:
2725
import pyarrow # type: ignore
2826
except ImportError:
@@ -101,14 +99,10 @@ def pyarrow_timestamp():
10199
pyarrow.decimal128(38, scale=9).id: "NUMERIC",
102100
}
103101

104-
# Adds bignumeric support only if pyarrow version >= 3.0.0
105-
# Decimal256 support was added to arrow 3.0.0
106-
# https://arrow.apache.org/blog/2021/01/25/3.0.0-release/
107-
if version.parse(pyarrow.__version__) >= version.parse("3.0.0"):
108-
_BQ_TO_ARROW_SCALARS["BIGNUMERIC"] = pyarrow_bignumeric
109-
# The exact decimal's scale and precision are not important, as only
110-
# the type ID matters, and it's the same for all decimal256 instances.
111-
_ARROW_SCALAR_IDS_TO_BQ[pyarrow.decimal256(76, scale=38).id] = "BIGNUMERIC"
102+
_BQ_TO_ARROW_SCALARS["BIGNUMERIC"] = pyarrow_bignumeric
103+
# The exact decimal's scale and precision are not important, as only
104+
# the type ID matters, and it's the same for all decimal256 instances.
105+
_ARROW_SCALAR_IDS_TO_BQ[pyarrow.decimal256(76, scale=38).id] = "BIGNUMERIC"
112106

113107

114108
def bq_to_arrow_scalars(bq_scalar: str):

google/cloud/bigquery/external_config.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,10 @@ def schema(self):
835835
See
836836
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#ExternalDataConfiguration.FIELDS.schema
837837
"""
838-
prop = self._properties.get("schema", {})
839-
return [SchemaField.from_api_repr(field) for field in prop.get("fields", [])]
838+
# TODO: The typehinting for this needs work. Setting this pragma to temporarily
839+
# manage a pytype issue that came up in another PR. See Issue: #2132
840+
prop = self._properties.get("schema", {}) # type: ignore
841+
return [SchemaField.from_api_repr(field) for field in prop.get("fields", [])] # type: ignore
840842

841843
@schema.setter
842844
def schema(self, value):

google/cloud/bigquery/format_options.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import copy
16-
from typing import Dict, Optional
16+
from typing import Dict, Optional, Union
1717

1818

1919
class AvroOptions:
@@ -106,7 +106,7 @@ def enable_list_inference(self, value: bool) -> None:
106106
self._properties["enableListInference"] = value
107107

108108
@property
109-
def map_target_type(self) -> str:
109+
def map_target_type(self) -> Optional[Union[bool, str]]:
110110
"""Indicates whether to simplify the representation of parquet maps to only show keys and values."""
111111

112112
return self._properties.get("mapTargetType")

google/cloud/bigquery/job/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,9 @@ def __init__(self, job_id, client):
415415
@property
416416
def configuration(self) -> _JobConfig:
417417
"""Job-type specific configurtion."""
418-
configuration = self._CONFIG_CLASS()
418+
# TODO: The typehinting for this needs work. Setting this pragma to temporarily
419+
# manage a pytype issue that came up in another PR. See Issue: #2132
420+
configuration = self._CONFIG_CLASS() # pytype: disable=not-callable
419421
configuration._properties = self._properties.setdefault("configuration", {})
420422
return configuration
421423

google/cloud/bigquery/magics/magics.py

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
except ImportError:
5656
bigquery_magics = None
5757

58-
5958
IPYTHON_USER_AGENT = "ipython-{}".format(IPython.__version__) # type: ignore
6059

6160

google/cloud/bigquery/model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, model_ref: Union["ModelReference", str, None]):
5858
# semantics. The BigQuery API makes a distinction between an unset
5959
# value, a null value, and a default value (0 or ""), but the protocol
6060
# buffer classes do not.
61-
self._properties = {}
61+
self._properties: Dict[str, Any] = {}
6262

6363
if isinstance(model_ref, str):
6464
model_ref = ModelReference.from_string(model_ref)

0 commit comments

Comments
 (0)