Skip to content

Commit

Permalink
chore: adds Python 3.7/3.8 EOL pending deprecation warning (#2007)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Sep 11, 2024
1 parent 1b4cca0 commit 847feb4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
13 changes: 13 additions & 0 deletions google/cloud/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,25 @@
from google.cloud.bigquery.table import TimePartitioningType
from google.cloud.bigquery.table import TimePartitioning
from google.cloud.bigquery.encryption_configuration import EncryptionConfiguration
from google.cloud.bigquery import _versions_helpers

try:
import bigquery_magics # type: ignore
except ImportError:
bigquery_magics = None

sys_major, sys_minor, sys_micro = _versions_helpers.extract_runtime_version()

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. "
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,
)

__all__ = [
"__version__",
"Client",
Expand Down
14 changes: 14 additions & 0 deletions google/cloud/bigquery/_versions_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

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

import sys
from typing import Any

import packaging.version
Expand Down Expand Up @@ -248,3 +249,16 @@ def try_import(self, raise_if_error: bool = False) -> Any:
and PYARROW_VERSIONS.try_import() is not None
and PYARROW_VERSIONS.installed_version >= _MIN_PYARROW_VERSION_RANGE
)


def extract_runtime_version():
# Retrieve the version information
version_info = sys.version_info

# Extract the major, minor, and micro components
major = version_info.major
minor = version_info.minor
micro = version_info.micro

# Display the version number in a clear format
return major, minor, micro
23 changes: 20 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def default(session, install_extras=True):
session.run(
"py.test",
"--quiet",
"-W default::PendingDeprecationWarning",
"--cov=google/cloud/bigquery",
"--cov=tests/unit",
"--cov-append",
Expand Down Expand Up @@ -231,6 +232,7 @@ def system(session):
session.run(
"py.test",
"--quiet",
"-W default::PendingDeprecationWarning",
os.path.join("tests", "system"),
*session.posargs,
)
Expand Down Expand Up @@ -299,6 +301,7 @@ def snippets(session):
session.run(
"py.test",
"samples",
"-W default::PendingDeprecationWarning",
"--ignore=samples/desktopapp",
"--ignore=samples/magics",
"--ignore=samples/geography",
Expand Down Expand Up @@ -401,9 +404,23 @@ def prerelease_deps(session):
session.run("python", "-m", "pip", "freeze")

# Run all tests, except a few samples tests which require extra dependencies.
session.run("py.test", "tests/unit")
session.run("py.test", "tests/system")
session.run("py.test", "samples/tests")
session.run(
"py.test",
"tests/unit",
"-W default::PendingDeprecationWarning",
)

session.run(
"py.test",
"tests/system",
"-W default::PendingDeprecationWarning",
)

session.run(
"py.test",
"samples/tests",
"-W default::PendingDeprecationWarning",
)


@nox.session(python=DEFAULT_PYTHON_VERSION)
Expand Down

0 comments on commit 847feb4

Please sign in to comment.