Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Update Python versions (drop 3.7, 3.8 and add 3.13) #2104

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
de83435
removes refs in install_deps.tmpl.rst
chalmerlowe Jan 8, 2025
50a9f4d
removes refs in README.rst
chalmerlowe Jan 8, 2025
71b19a9
updates __init__
chalmerlowe Jan 9, 2025
94a15d9
Updates user_credentials_test.py
chalmerlowe Jan 9, 2025
907d77d
updates noxfile.py
chalmerlowe Jan 9, 2025
d5adf2b
Merge branch 'main' into fix-b387301099-remove-python-37-38-add-313
chalmerlowe Jan 9, 2025
75a3ef8
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jan 9, 2025
b181341
Merge branch 'fix-b387301099-remove-python-37-38-add-313' of https://…
gcf-owl-bot[bot] Jan 9, 2025
9e113bc
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jan 9, 2025
a0442a7
Merge branch 'fix-b387301099-remove-python-37-38-add-313' of https://…
gcf-owl-bot[bot] Jan 9, 2025
058de0d
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jan 9, 2025
dce9153
Merge branch 'fix-b387301099-remove-python-37-38-add-313' of https://…
gcf-owl-bot[bot] Jan 9, 2025
0212e03
Updates noxfile.py and removes typing-extension ref
chalmerlowe Jan 15, 2025
5ebe2ba
Updates pyproject.toml, adds testing-constraints-3.13.txt
chalmerlowe Jan 15, 2025
5bc77ab
Updates docs/conf.py removes blank lines
chalmerlowe Jan 15, 2025
2305957
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jan 15, 2025
e407a5f
Updates minimum value of pyarrow in the noxfile.py
chalmerlowe Jan 15, 2025
48c064d
chore(python): exclude .github/workflows/unittest.yml in renovate con…
gcf-owl-bot[bot] Jan 9, 2025
2b7d088
feat: adds new input validation function similar to isinstance. (#2107)
chalmerlowe Jan 9, 2025
de45810
feat: adds the SerDeInfo class and tests (#2108)
chalmerlowe Jan 10, 2025
677bfcc
feat: adds StorageDescriptor and tests (#2109)
chalmerlowe Jan 14, 2025
04a335c
feat: resource tags in dataset (#2090)
keunsoopark Jan 14, 2025
ad71754
feat: Adds ForeignTypeInfo class and tests (#2110)
chalmerlowe Jan 15, 2025
7a07d5a
feat: adds ExternalCatalogDatasetOptions and tests (#2111)
chalmerlowe Jan 15, 2025
7fb624b
chore(main): release 3.28.0 (#2056)
release-please[bot] Jan 15, 2025
bca7c56
fix: add default value in SchemaField.from_api_repr() (#2115)
Linchin Jan 17, 2025
e9caef7
feat: add ExternalCatalogTableOptions class and tests (#2116)
chalmerlowe Jan 21, 2025
f6b3235
updates noxfile and adds constraints-3.13.txt
chalmerlowe Jan 21, 2025
6667e4b
Update to external_config, setup.py, noxfile.py
chalmerlowe Jan 22, 2025
78da415
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jan 22, 2025
a0264d8
Merge branch 'main' into fix-b387301099-remove-python-37-38-add-313
chalmerlowe Jan 22, 2025
d5e180d
remove 3.7 and 3.8 configs
chalmerlowe Jan 22, 2025
a468977
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jan 22, 2025
ffc0dba
Removes 3.7 and 3.8 configs that owlbot recreated
chalmerlowe Jan 22, 2025
f1b6871
removes 3.7 and 3.8 from samples/noteboooks
chalmerlowe Jan 22, 2025
c3e6c6b
Updates to manage mypy errors
chalmerlowe Jan 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .kokoro/presubmit/snippets-3.8.cfg

This file was deleted.

7 changes: 0 additions & 7 deletions .kokoro/presubmit/system-3.8.cfg

This file was deleted.

40 changes: 0 additions & 40 deletions .kokoro/samples/python3.7/common.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions .kokoro/samples/python3.7/continuous.cfg

This file was deleted.

11 changes: 0 additions & 11 deletions .kokoro/samples/python3.7/periodic-head.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions .kokoro/samples/python3.7/periodic.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions .kokoro/samples/python3.7/presubmit.cfg

This file was deleted.

40 changes: 0 additions & 40 deletions .kokoro/samples/python3.8/common.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions .kokoro/samples/python3.8/continuous.cfg

This file was deleted.

11 changes: 0 additions & 11 deletions .kokoro/samples/python3.8/periodic-head.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions .kokoro/samples/python3.8/periodic.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions .kokoro/samples/python3.8/presubmit.cfg

This file was deleted.

4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ dependencies.

Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
Python >= 3.7
Python >= 3.9

Unsupported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7, Python == 3.5, Python == 3.6.
Python == 2.7, Python == 3.5, Python == 3.6, Python == 3.7, Python == 3.8.

The last version of this library compatible with Python 2.7 and 3.5 is
`google-cloud-bigquery==1.28.0`.
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@

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

__all__ = [
Expand Down
9 changes: 7 additions & 2 deletions google/cloud/bigquery/external_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import base64
import copy
import typing
from typing import Any, Dict, FrozenSet, Iterable, Optional, Union

from google.cloud.bigquery._helpers import _to_bytes
Expand Down Expand Up @@ -835,11 +836,15 @@ def schema(self):
See
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#ExternalDataConfiguration.FIELDS.schema
"""

prop = self._properties.get("schema", {})
return [SchemaField.from_api_repr(field) for field in prop.get("fields", [])]
return [
SchemaField.from_api_repr(field)
for field in typing.cast(dict, prop).get("fields", [])
]

@schema.setter
def schema(self, value):
def schema(self, value: Union[list, dict, None]):
prop = value
if value is not None:
prop = {"fields": [field.to_api_repr() for field in value]}
Expand Down
21 changes: 11 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


MYPY_VERSION = "mypy==1.6.1"
PYTYPE_VERSION = "pytype==2021.4.9"
PYTYPE_VERSION = "pytype==2024.9.13"
BLACK_VERSION = "black==23.7.0"
BLACK_PATHS = (
"benchmark",
Expand All @@ -37,9 +37,9 @@
"setup.py",
)

DEFAULT_PYTHON_VERSION = "3.8"
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.11", "3.12"]
UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.12"]
DEFAULT_PYTHON_VERSION = "3.10"
SYSTEM_TEST_PYTHON_VERSIONS = ["3.9", "3.12", "3.13"] # oldest, two most recent
UNIT_TEST_PYTHON_VERSIONS = ["3.9", "3.12", "3.13"] # oldest, two most recent
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()


Expand Down Expand Up @@ -103,7 +103,8 @@ def default(session, install_extras=True):
constraints_path,
)

if install_extras and session.python in ["3.11", "3.12"]:
# Testing two highest versions with extras
if install_extras and session.python in UNIT_TEST_PYTHON_VERSIONS[-2:]:
install_target = ".[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
elif install_extras:
install_target = ".[all]"
Expand Down Expand Up @@ -136,6 +137,7 @@ def unit(session):
default(session)


# Testing lowest and highest with no extras
@nox.session(python=[UNIT_TEST_PYTHON_VERSIONS[0], UNIT_TEST_PYTHON_VERSIONS[-1]])
@_calculate_duration
def unit_noextras(session):
Expand All @@ -149,7 +151,7 @@ def unit_noextras(session):
# so that it continues to be an optional dependency.
# https://github.com/googleapis/python-bigquery/issues/1877
if session.python == UNIT_TEST_PYTHON_VERSIONS[0]:
session.install("pyarrow==1.0.0")
session.install("pyarrow==5.0.0")

default(session, install_extras=False)

Expand Down Expand Up @@ -222,7 +224,7 @@ def system(session):
# Resource Manager needed for test with a real Resource Tag.
session.install("google-cloud-resource-manager", "-c", constraints_path)

if session.python in ["3.11", "3.12"]:
if session.python in SYSTEM_TEST_PYTHON_VERSIONS[-2]: # two most recent
extras = "[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
else:
extras = "[all]"
Expand Down Expand Up @@ -266,8 +268,6 @@ def mypy_samples(session):
"types-setuptools",
)

session.install("typing-extensions") # for TypedDict in pre-3.8 Python versions

session.run(
"mypy",
"--config-file",
Expand All @@ -291,7 +291,8 @@ def snippets(session):
session.install("google-cloud-storage", "-c", constraints_path)
session.install("grpcio", "-c", constraints_path)

if session.python in ["3.11", "3.12"]:
# Testing snippets against two most recent versions
if session.python in UNIT_TEST_PYTHON_VERSIONS[-2:]:
extras = "[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
else:
extras = "[all]"
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ build-backend = "setuptools.build_meta"
name = "google-cloud-bigquery"
authors = [{ name = "Google LLC", email = "googleapis-packages@google.com" }]
license = { text = "Apache 2.0" }
requires-python = ">=3.7"
requires-python = ">=3.9"
description = "Google BigQuery API client library"
readme = "README.rst"
classifiers = [
Expand All @@ -33,12 +33,11 @@ classifiers = [
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: OS Independent",
"Topic :: Internet",
]
Expand Down Expand Up @@ -76,7 +75,6 @@ pandas = [
"pandas >= 1.1.0",
"pyarrow >= 3.0.0",
"db-dtypes >= 0.3.0, < 2.0.0dev",
"importlib_metadata >= 1.0.0; python_version < '3.8'",
]
ipywidgets = ["ipywidgets >= 7.7.0", "ipykernel >= 6.0.0"]
geopandas = ["geopandas >= 0.9.0, < 2.0dev", "Shapely >= 1.8.4, < 3.0.0dev"]
Expand Down
9 changes: 1 addition & 8 deletions samples/desktopapp/user_credentials_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import sys
from typing import Iterator, Union
from unittest import mock

Expand All @@ -24,13 +23,7 @@

PROJECT = os.environ["GOOGLE_CLOUD_PROJECT"]


if sys.version_info >= (3, 8):
# Python 3.8+ has an AsyncMock attribute in unittest.mock, but 3.7 does not
MockType = Union[mock.MagicMock, mock.AsyncMock]
else:
# Other definitions and imports
MockType = Union[mock.MagicMock]
MockType = Union[mock.MagicMock, mock.AsyncMock]


@pytest.fixture
Expand Down
7 changes: 4 additions & 3 deletions samples/magics/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import pytest

if typing.TYPE_CHECKING:
from IPython.core.interactiveshell import TerminalInteractiveShell
from IPython.terminal.interactiveshell import TerminalInteractiveShell

interactiveshell = pytest.importorskip("IPython.terminal.interactiveshell")
tools = pytest.importorskip("IPython.testing.tools")
Expand All @@ -40,5 +40,6 @@ def ipython_interactive(

for the duration of the test scope.
"""
with ipython.builtin_trap:
yield ipython
if ipython.builtin_trap is not None:
with ipython.builtin_trap:
yield ipython
6 changes: 4 additions & 2 deletions samples/notebooks/jupyter_tutorial_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ def ipython_interactive(

for the duration of the test scope.
"""
with ipython.builtin_trap:
yield ipython

if ipython.builtin_trap is not None:
with ipython.builtin_trap:
yield ipython


def _strip_region_tags(sample_text: str) -> str:
Expand Down
Loading
Loading