Skip to content

Commit 9bf496a

Browse files
committed
feat: add grace period for 3.9; tweak warning
The warning messages now mor eclosely match what we'we're deploying in the generator for those who don't update their api-core dependency
1 parent fe6aa6d commit 9bf496a

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

google/api_core/_python_version_support.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class VersionInfo(NamedTuple):
6060
python_beta=datetime.date(2020, 5, 18),
6161
python_start=datetime.date(2020, 10, 5),
6262
python_eol=datetime.date(2025, 10, 5), # TODO: specify day when announced
63+
gapic_end=datetime.date(2025, 10, 5) + datetime.timedelta(days=90), # TODO: specify day when announced
6364
),
6465
(3, 10): VersionInfo(
6566
python_beta=datetime.date(2021, 5, 3),
@@ -155,7 +156,7 @@ def check_python_version(
155156

156157
python_version = sys.version_info
157158
version_tuple = (python_version.major, python_version.minor)
158-
py_version_str = f"{python_version.major}.{python_version.minor}"
159+
py_version_str = sys.version.split()[0]
159160

160161
version_info = PYTHON_VERSION_INFO.get(version_tuple)
161162

@@ -188,11 +189,11 @@ def min_python(date: datetime.date) -> str:
188189
if gapic_end < today:
189190
message = _flatten_message(
190191
f"""
191-
You are using a non-supported Python version
192-
({py_version_str}). Google will not post any further
193-
updates to {package_label}. Please upgrade to the
194-
latest Python version, or at least Python
195-
{min_python(today)}, and then update {package_label}.
192+
You are using a non-supported Python version ({py_version_str}).
193+
Google will not post any further updates to {package_label}
194+
supporting this Python version. Please upgrade to the latest Python
195+
version, or at least Python {min_python(today)}, and then update
196+
{package_label}.
196197
"""
197198
)
198199
warnings.warn(message, FutureWarning)
@@ -216,12 +217,12 @@ def min_python(date: datetime.date) -> str:
216217
if gapic_deprecation <= today <= gapic_end:
217218
message = _flatten_message(
218219
f"""
219-
You are using a Python version ({py_version_str})
220-
which Google will stop supporting in {package_label} when
221-
it reaches its end of life ({version_info.python_eol}). Please
222-
upgrade to the latest Python version, or at
223-
least Python {min_python(version_info.python_eol)}, and
224-
then update {package_label}.
220+
You are using a Python version ({py_version_str}) which Google will
221+
stop supporting in new releases of {package_label} once it reaches
222+
its end of life ({version_info.python_eol}). Please upgrade to the
223+
latest Python version, or at least Python
224+
{min_python(version_info.python_eol)}, to continue receiving updates
225+
for {package_label} past that date.
225226
"""
226227
)
227228
warnings.warn(message, FutureWarning)

0 commit comments

Comments
 (0)