Skip to content

Commit 133a1e0

Browse files
committed
feat: apply Python version suport warnings to api_core
1 parent c868c2a commit 133a1e0

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

google/api_core/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@
2222

2323
__version__ = api_core_version.__version__
2424
check_python_version = _python_version_support.check_python_version
25+
check_python_version(package="package google-api-core (google.api_core)")

google/api_core/_python_version_support.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class VersionInfo(NamedTuple):
3737
python_beta: Optional[datetime.date]
3838
python_start: datetime.date
3939
python_eol: datetime.date
40-
gapic_start: Optional[datetime.date] = None
40+
gapic_start: Optional[datetime.date] = None # unused
4141
gapic_deprecation: Optional[datetime.date] = None
4242
gapic_end: Optional[datetime.date] = None
43-
dep_unpatchable_cve: Optional[datetime.date] = None
43+
dep_unpatchable_cve: Optional[datetime.date] = None # unused
4444

4545

4646
PYTHON_VERSION_INFO: Dict[Tuple[int, int], VersionInfo] = {
@@ -97,7 +97,8 @@ def _flatten_message(text: str) -> str:
9797
return textwrap.dedent(text).strip().replace("\n", " ")
9898

9999

100-
def check_python_version(today: Optional[datetime.date] = None) -> PythonVersionStatus:
100+
def check_python_version(package: Optional[str] = "this package",
101+
today: Optional[datetime.date] = None) -> PythonVersionStatus:
101102
"""Check the running Python version and issue a support warning if needed.
102103
103104
Args:
@@ -146,9 +147,9 @@ def min_python(date: datetime.date) -> str:
146147
message = _flatten_message(
147148
f"""
148149
You are using a non-supported Python version ({py_version_str}).
149-
You will receive no updates to this client library. We suggest
150+
Google will not post any further updates to {package}. We suggest
150151
you upgrade to the latest Python version, or at least Python
151-
{min_python(today)}, and then update this library.
152+
{min_python(today)}, and then update {package}.
152153
"""
153154
)
154155
logging.warning(message)
@@ -159,11 +160,10 @@ def min_python(date: datetime.date) -> str:
159160
message = _flatten_message(
160161
f"""
161162
You are using a Python version ({py_version_str}) past its end
162-
of life. This client library will continue receiving critical
163-
bug fixes on a best-effort basis, but not any other fixes or
163+
of life. Google will update {package} with critical
164+
bug fixes on a best-effort basis, but not with any other fixes or
164165
features. We suggest you upgrade to the latest Python version,
165-
or at least Python {min_python(today)}, and then update this
166-
library.
166+
or at least Python {min_python(today)}, and then update {package}.
167167
"""
168168
)
169169
logging.warning(message)
@@ -172,12 +172,12 @@ def min_python(date: datetime.date) -> str:
172172
if gapic_deprecation <= today <= gapic_end:
173173
message = _flatten_message(
174174
f"""
175-
You are using a Python version ({py_version_str}), which new
176-
releases of this client library will stop supporting when it
175+
You are using a Python version ({py_version_str}),
176+
which Google will stop supporting in {package} when it
177177
reaches its end of life ({version_info.python_eol}). We
178-
suggest you upgrade to the latest Python version, or at least
179-
Python {min_python(version_info.python_eol)}, and then update
180-
this library.
178+
suggest you upgrade to the latest Python version, or at
179+
least Python {min_python(version_info.python_eol)}, and
180+
then update {package}.
181181
"""
182182
)
183183
logging.warning(message)

0 commit comments

Comments
 (0)