Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit dd1a244

Browse files
committed
Use warnings module instead of logging module
1 parent 34eb7ab commit dd1a244

File tree

8 files changed

+176
-176
lines changed

8 files changed

+176
-176
lines changed

gapic/templates/%namespace/%name_%version/%sub/__init__.py.j2

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ else: # pragma: NO COVER
3030
_py_version_str = sys.version.split()[0]
3131
_package_label = "{{package_path}}"
3232
if sys.version_info < (3, 9):
33-
logging.warning("You are using a non-supported Python version " +
34-
f"({_py_version_str}). Google will not post any further " +
35-
f"updates to {_package_label} supporting this Python version. " +
36-
"Please upgrade to the latest Python version, or at " +
37-
f"least to Python 3.9, and then update {_package_label}.")
33+
warnings.warn("You are using a non-supported Python version " +
34+
f"({_py_version_str}). Google will not post any further " +
35+
f"updates to {_package_label} supporting this Python version. " +
36+
"Please upgrade to the latest Python version, or at " +
37+
f"least to Python 3.9, and then update {_package_label}.")
3838
if sys.version_info[:2] == (3, 9):
39-
logging.warning(f"You are using a Python version ({_py_version_str}) " +
40-
f"which Google will stop supporting in {_package_label} when " +
41-
"it reaches its end of life (October 2025). Please " +
42-
"upgrade to the latest Python version, or at " +
43-
"least Python 3.10, before then, and " +
44-
f"then update {_package_label}.")
39+
warnings.warn(f"You are using a Python version ({_py_version_str}) " +
40+
f"which Google will stop supporting in {_package_label} when " +
41+
"it reaches its end of life (October 2025). Please " +
42+
"upgrade to the latest Python version, or at " +
43+
"least Python 3.10, before then, and " +
44+
f"then update {_package_label}.")
4545

4646
from packaging.version import parse as parse_version
4747

@@ -70,17 +70,17 @@ else: # pragma: NO COVER
7070
_next_supported_version_tuple = (4, 25, 8)
7171
_version_used = _get_version(_dependency_package)
7272
if _version_used and _version_used < _next_supported_version_tuple:
73-
logging.warning(f"DEPRECATION: Package {_package_label} depends on " +
74-
f"{_dependency_package}, currently installed at version " +
75-
f"{_version_used.__str__}. Future updates to " +
76-
f"{_package_label} will require {_dependency_package} at " +
77-
f"version {_next_supported_version} or higher. Please ensure " +
78-
"that either (a) your Python environment doesn't pin the " +
79-
f"version of {_dependency_package}, so that updates to " +
80-
f"{_package_label} can require the higher version, or " +
81-
"(b) you manually update your Python environment to use at " +
82-
f"least version {_next_supported_version} of " +
83-
f"{_dependency_package}.")
73+
warnings.warn(f"DEPRECATION: Package {_package_label} depends on " +
74+
f"{_dependency_package}, currently installed at version " +
75+
f"{_version_used.__str__}. Future updates to " +
76+
f"{_package_label} will require {_dependency_package} at " +
77+
f"version {_next_supported_version} or higher. Please ensure " +
78+
"that either (a) your Python environment doesn't pin the " +
79+
f"version of {_dependency_package}, so that updates to " +
80+
f"{_package_label} can require the higher version, or " +
81+
"(b) you manually update your Python environment to use at " +
82+
f"least version {_next_supported_version} of " +
83+
f"{_dependency_package}.")
8484

8585
{# Import subpackages. -#}
8686
{% for subpackage, _ in api.subpackages|dictsort %}

tests/integration/goldens/asset/google/cloud/asset_v1/__init__.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333
_py_version_str = sys.version.split()[0]
3434
_package_label = "google.cloud.asset_v1"
3535
if sys.version_info < (3, 9):
36-
logging.warning("You are using a non-supported Python version " +
37-
f"({_py_version_str}). Google will not post any further " +
38-
f"updates to {_package_label} supporting this Python version. " +
39-
"Please upgrade to the latest Python version, or at " +
40-
f"least to Python 3.9, and then update {_package_label}.")
36+
warnings.warn("You are using a non-supported Python version " +
37+
f"({_py_version_str}). Google will not post any further " +
38+
f"updates to {_package_label} supporting this Python version. " +
39+
"Please upgrade to the latest Python version, or at " +
40+
f"least to Python 3.9, and then update {_package_label}.")
4141
if sys.version_info[:2] == (3, 9):
42-
logging.warning(f"You are using a Python version ({_py_version_str}) " +
43-
f"which Google will stop supporting in {_package_label} when " +
44-
"it reaches its end of life (October 2025). Please " +
45-
"upgrade to the latest Python version, or at " +
46-
"least Python 3.10, before then, and " +
47-
f"then update {_package_label}.")
42+
warnings.warn(f"You are using a Python version ({_py_version_str}) " +
43+
f"which Google will stop supporting in {_package_label} when " +
44+
"it reaches its end of life (October 2025). Please " +
45+
"upgrade to the latest Python version, or at " +
46+
"least Python 3.10, before then, and " +
47+
f"then update {_package_label}.")
4848

4949
from packaging.version import parse as parse_version
5050

@@ -73,17 +73,17 @@ def _get_version(dependency_name):
7373
_next_supported_version_tuple = (4, 25, 8)
7474
_version_used = _get_version(_dependency_package)
7575
if _version_used and _version_used < _next_supported_version_tuple:
76-
logging.warning(f"DEPRECATION: Package {_package_label} depends on " +
77-
f"{_dependency_package}, currently installed at version " +
78-
f"{_version_used.__str__}. Future updates to " +
79-
f"{_package_label} will require {_dependency_package} at " +
80-
f"version {_next_supported_version} or higher. Please ensure " +
81-
"that either (a) your Python environment doesn't pin the " +
82-
f"version of {_dependency_package}, so that updates to " +
83-
f"{_package_label} can require the higher version, or " +
84-
"(b) you manually update your Python environment to use at " +
85-
f"least version {_next_supported_version} of " +
86-
f"{_dependency_package}.")
76+
warnings.warn(f"DEPRECATION: Package {_package_label} depends on " +
77+
f"{_dependency_package}, currently installed at version " +
78+
f"{_version_used.__str__}. Future updates to " +
79+
f"{_package_label} will require {_dependency_package} at " +
80+
f"version {_next_supported_version} or higher. Please ensure " +
81+
"that either (a) your Python environment doesn't pin the " +
82+
f"version of {_dependency_package}, so that updates to " +
83+
f"{_package_label} can require the higher version, or " +
84+
"(b) you manually update your Python environment to use at " +
85+
f"least version {_next_supported_version} of " +
86+
f"{_dependency_package}.")
8787

8888

8989
from .services.asset_service import AssetServiceClient

tests/integration/goldens/credentials/google/iam/credentials_v1/__init__.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333
_py_version_str = sys.version.split()[0]
3434
_package_label = "google.iam.credentials_v1"
3535
if sys.version_info < (3, 9):
36-
logging.warning("You are using a non-supported Python version " +
37-
f"({_py_version_str}). Google will not post any further " +
38-
f"updates to {_package_label} supporting this Python version. " +
39-
"Please upgrade to the latest Python version, or at " +
40-
f"least to Python 3.9, and then update {_package_label}.")
36+
warnings.warn("You are using a non-supported Python version " +
37+
f"({_py_version_str}). Google will not post any further " +
38+
f"updates to {_package_label} supporting this Python version. " +
39+
"Please upgrade to the latest Python version, or at " +
40+
f"least to Python 3.9, and then update {_package_label}.")
4141
if sys.version_info[:2] == (3, 9):
42-
logging.warning(f"You are using a Python version ({_py_version_str}) " +
43-
f"which Google will stop supporting in {_package_label} when " +
44-
"it reaches its end of life (October 2025). Please " +
45-
"upgrade to the latest Python version, or at " +
46-
"least Python 3.10, before then, and " +
47-
f"then update {_package_label}.")
42+
warnings.warn(f"You are using a Python version ({_py_version_str}) " +
43+
f"which Google will stop supporting in {_package_label} when " +
44+
"it reaches its end of life (October 2025). Please " +
45+
"upgrade to the latest Python version, or at " +
46+
"least Python 3.10, before then, and " +
47+
f"then update {_package_label}.")
4848

4949
from packaging.version import parse as parse_version
5050

@@ -73,17 +73,17 @@ def _get_version(dependency_name):
7373
_next_supported_version_tuple = (4, 25, 8)
7474
_version_used = _get_version(_dependency_package)
7575
if _version_used and _version_used < _next_supported_version_tuple:
76-
logging.warning(f"DEPRECATION: Package {_package_label} depends on " +
77-
f"{_dependency_package}, currently installed at version " +
78-
f"{_version_used.__str__}. Future updates to " +
79-
f"{_package_label} will require {_dependency_package} at " +
80-
f"version {_next_supported_version} or higher. Please ensure " +
81-
"that either (a) your Python environment doesn't pin the " +
82-
f"version of {_dependency_package}, so that updates to " +
83-
f"{_package_label} can require the higher version, or " +
84-
"(b) you manually update your Python environment to use at " +
85-
f"least version {_next_supported_version} of " +
86-
f"{_dependency_package}.")
76+
warnings.warn(f"DEPRECATION: Package {_package_label} depends on " +
77+
f"{_dependency_package}, currently installed at version " +
78+
f"{_version_used.__str__}. Future updates to " +
79+
f"{_package_label} will require {_dependency_package} at " +
80+
f"version {_next_supported_version} or higher. Please ensure " +
81+
"that either (a) your Python environment doesn't pin the " +
82+
f"version of {_dependency_package}, so that updates to " +
83+
f"{_package_label} can require the higher version, or " +
84+
"(b) you manually update your Python environment to use at " +
85+
f"least version {_next_supported_version} of " +
86+
f"{_dependency_package}.")
8787

8888

8989
from .services.iam_credentials import IAMCredentialsClient

tests/integration/goldens/eventarc/google/cloud/eventarc_v1/__init__.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333
_py_version_str = sys.version.split()[0]
3434
_package_label = "google.cloud.eventarc_v1"
3535
if sys.version_info < (3, 9):
36-
logging.warning("You are using a non-supported Python version " +
37-
f"({_py_version_str}). Google will not post any further " +
38-
f"updates to {_package_label} supporting this Python version. " +
39-
"Please upgrade to the latest Python version, or at " +
40-
f"least to Python 3.9, and then update {_package_label}.")
36+
warnings.warn("You are using a non-supported Python version " +
37+
f"({_py_version_str}). Google will not post any further " +
38+
f"updates to {_package_label} supporting this Python version. " +
39+
"Please upgrade to the latest Python version, or at " +
40+
f"least to Python 3.9, and then update {_package_label}.")
4141
if sys.version_info[:2] == (3, 9):
42-
logging.warning(f"You are using a Python version ({_py_version_str}) " +
43-
f"which Google will stop supporting in {_package_label} when " +
44-
"it reaches its end of life (October 2025). Please " +
45-
"upgrade to the latest Python version, or at " +
46-
"least Python 3.10, before then, and " +
47-
f"then update {_package_label}.")
42+
warnings.warn(f"You are using a Python version ({_py_version_str}) " +
43+
f"which Google will stop supporting in {_package_label} when " +
44+
"it reaches its end of life (October 2025). Please " +
45+
"upgrade to the latest Python version, or at " +
46+
"least Python 3.10, before then, and " +
47+
f"then update {_package_label}.")
4848

4949
from packaging.version import parse as parse_version
5050

@@ -73,17 +73,17 @@ def _get_version(dependency_name):
7373
_next_supported_version_tuple = (4, 25, 8)
7474
_version_used = _get_version(_dependency_package)
7575
if _version_used and _version_used < _next_supported_version_tuple:
76-
logging.warning(f"DEPRECATION: Package {_package_label} depends on " +
77-
f"{_dependency_package}, currently installed at version " +
78-
f"{_version_used.__str__}. Future updates to " +
79-
f"{_package_label} will require {_dependency_package} at " +
80-
f"version {_next_supported_version} or higher. Please ensure " +
81-
"that either (a) your Python environment doesn't pin the " +
82-
f"version of {_dependency_package}, so that updates to " +
83-
f"{_package_label} can require the higher version, or " +
84-
"(b) you manually update your Python environment to use at " +
85-
f"least version {_next_supported_version} of " +
86-
f"{_dependency_package}.")
76+
warnings.warn(f"DEPRECATION: Package {_package_label} depends on " +
77+
f"{_dependency_package}, currently installed at version " +
78+
f"{_version_used.__str__}. Future updates to " +
79+
f"{_package_label} will require {_dependency_package} at " +
80+
f"version {_next_supported_version} or higher. Please ensure " +
81+
"that either (a) your Python environment doesn't pin the " +
82+
f"version of {_dependency_package}, so that updates to " +
83+
f"{_package_label} can require the higher version, or " +
84+
"(b) you manually update your Python environment to use at " +
85+
f"least version {_next_supported_version} of " +
86+
f"{_dependency_package}.")
8787

8888

8989
from .services.eventarc import EventarcClient

tests/integration/goldens/logging/google/cloud/logging_v2/__init__.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333
_py_version_str = sys.version.split()[0]
3434
_package_label = "google.cloud.logging_v2"
3535
if sys.version_info < (3, 9):
36-
logging.warning("You are using a non-supported Python version " +
37-
f"({_py_version_str}). Google will not post any further " +
38-
f"updates to {_package_label} supporting this Python version. " +
39-
"Please upgrade to the latest Python version, or at " +
40-
f"least to Python 3.9, and then update {_package_label}.")
36+
warnings.warn("You are using a non-supported Python version " +
37+
f"({_py_version_str}). Google will not post any further " +
38+
f"updates to {_package_label} supporting this Python version. " +
39+
"Please upgrade to the latest Python version, or at " +
40+
f"least to Python 3.9, and then update {_package_label}.")
4141
if sys.version_info[:2] == (3, 9):
42-
logging.warning(f"You are using a Python version ({_py_version_str}) " +
43-
f"which Google will stop supporting in {_package_label} when " +
44-
"it reaches its end of life (October 2025). Please " +
45-
"upgrade to the latest Python version, or at " +
46-
"least Python 3.10, before then, and " +
47-
f"then update {_package_label}.")
42+
warnings.warn(f"You are using a Python version ({_py_version_str}) " +
43+
f"which Google will stop supporting in {_package_label} when " +
44+
"it reaches its end of life (October 2025). Please " +
45+
"upgrade to the latest Python version, or at " +
46+
"least Python 3.10, before then, and " +
47+
f"then update {_package_label}.")
4848

4949
from packaging.version import parse as parse_version
5050

@@ -73,17 +73,17 @@ def _get_version(dependency_name):
7373
_next_supported_version_tuple = (4, 25, 8)
7474
_version_used = _get_version(_dependency_package)
7575
if _version_used and _version_used < _next_supported_version_tuple:
76-
logging.warning(f"DEPRECATION: Package {_package_label} depends on " +
77-
f"{_dependency_package}, currently installed at version " +
78-
f"{_version_used.__str__}. Future updates to " +
79-
f"{_package_label} will require {_dependency_package} at " +
80-
f"version {_next_supported_version} or higher. Please ensure " +
81-
"that either (a) your Python environment doesn't pin the " +
82-
f"version of {_dependency_package}, so that updates to " +
83-
f"{_package_label} can require the higher version, or " +
84-
"(b) you manually update your Python environment to use at " +
85-
f"least version {_next_supported_version} of " +
86-
f"{_dependency_package}.")
76+
warnings.warn(f"DEPRECATION: Package {_package_label} depends on " +
77+
f"{_dependency_package}, currently installed at version " +
78+
f"{_version_used.__str__}. Future updates to " +
79+
f"{_package_label} will require {_dependency_package} at " +
80+
f"version {_next_supported_version} or higher. Please ensure " +
81+
"that either (a) your Python environment doesn't pin the " +
82+
f"version of {_dependency_package}, so that updates to " +
83+
f"{_package_label} can require the higher version, or " +
84+
"(b) you manually update your Python environment to use at " +
85+
f"least version {_next_supported_version} of " +
86+
f"{_dependency_package}.")
8787

8888

8989
from .services.config_service_v2 import ConfigServiceV2Client

0 commit comments

Comments
 (0)