Skip to content

Commit 847feb4

Browse files
chalmerlowegcf-owl-bot[bot]Linchin
authored
chore: adds Python 3.7/3.8 EOL pending deprecation warning (#2007)
* adds pending deprecation warning * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revise code to put version function in version helpers * Update noxfile.py * Update google/cloud/bigquery/__init__.py --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Lingqing Gan <[email protected]>
1 parent 1b4cca0 commit 847feb4

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

google/cloud/bigquery/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,25 @@
115115
from google.cloud.bigquery.table import TimePartitioningType
116116
from google.cloud.bigquery.table import TimePartitioning
117117
from google.cloud.bigquery.encryption_configuration import EncryptionConfiguration
118+
from google.cloud.bigquery import _versions_helpers
118119

119120
try:
120121
import bigquery_magics # type: ignore
121122
except ImportError:
122123
bigquery_magics = None
123124

125+
sys_major, sys_minor, sys_micro = _versions_helpers.extract_runtime_version()
126+
127+
if sys_major == 3 and sys_minor in (7, 8):
128+
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. "
131+
f"Your Python version is {sys_major}.{sys_minor}.{sys_micro}. We "
132+
"recommend that you update soon to ensure ongoing support. For "
133+
"more details, see: [Google Cloud Client Libraries Supported Python Versions policy](https://cloud.google.com/python/docs/supported-python-versions)",
134+
PendingDeprecationWarning,
135+
)
136+
124137
__all__ = [
125138
"__version__",
126139
"Client",

google/cloud/bigquery/_versions_helpers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""Shared helper functions for verifying versions of installed modules."""
1616

17+
import sys
1718
from typing import Any
1819

1920
import packaging.version
@@ -248,3 +249,16 @@ def try_import(self, raise_if_error: bool = False) -> Any:
248249
and PYARROW_VERSIONS.try_import() is not None
249250
and PYARROW_VERSIONS.installed_version >= _MIN_PYARROW_VERSION_RANGE
250251
)
252+
253+
254+
def extract_runtime_version():
255+
# Retrieve the version information
256+
version_info = sys.version_info
257+
258+
# Extract the major, minor, and micro components
259+
major = version_info.major
260+
minor = version_info.minor
261+
micro = version_info.micro
262+
263+
# Display the version number in a clear format
264+
return major, minor, micro

noxfile.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def default(session, install_extras=True):
116116
session.run(
117117
"py.test",
118118
"--quiet",
119+
"-W default::PendingDeprecationWarning",
119120
"--cov=google/cloud/bigquery",
120121
"--cov=tests/unit",
121122
"--cov-append",
@@ -231,6 +232,7 @@ def system(session):
231232
session.run(
232233
"py.test",
233234
"--quiet",
235+
"-W default::PendingDeprecationWarning",
234236
os.path.join("tests", "system"),
235237
*session.posargs,
236238
)
@@ -299,6 +301,7 @@ def snippets(session):
299301
session.run(
300302
"py.test",
301303
"samples",
304+
"-W default::PendingDeprecationWarning",
302305
"--ignore=samples/desktopapp",
303306
"--ignore=samples/magics",
304307
"--ignore=samples/geography",
@@ -401,9 +404,23 @@ def prerelease_deps(session):
401404
session.run("python", "-m", "pip", "freeze")
402405

403406
# Run all tests, except a few samples tests which require extra dependencies.
404-
session.run("py.test", "tests/unit")
405-
session.run("py.test", "tests/system")
406-
session.run("py.test", "samples/tests")
407+
session.run(
408+
"py.test",
409+
"tests/unit",
410+
"-W default::PendingDeprecationWarning",
411+
)
412+
413+
session.run(
414+
"py.test",
415+
"tests/system",
416+
"-W default::PendingDeprecationWarning",
417+
)
418+
419+
session.run(
420+
"py.test",
421+
"samples/tests",
422+
"-W default::PendingDeprecationWarning",
423+
)
407424

408425

409426
@nox.session(python=DEFAULT_PYTHON_VERSION)

0 commit comments

Comments
 (0)