-
Notifications
You must be signed in to change notification settings - Fork 95
feat: provide and use Python version support check #832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
6316d70
a136ad7
45cd647
25225fa
1d567c0
f1dbbb4
e3fd56f
8b1dfb1
4b9208e
5cf8652
7d8b1c7
cda8e27
db92fac
118a7c8
f1c46aa
474ec0d
2083b49
4ea124e
c5949c4
6fc1473
8829e20
bdb6260
7896664
54a5611
2e2990b
35a2074
cd64832
e36414a
b6245ca
3a897ba
814ea63
8dee04b
95f4777
a34ec15
a04e2e6
8b3f337
29896cf
d421f98
ac76f7a
e093a96
187f848
b575a16
ecb7211
3c587cf
fbe0f0b
28b0b32
21c9aec
e24c13d
dbc3a26
d472bae
0550f83
491b695
6338389
05bcf6f
fc224b7
a6c40ce
d0414b2
835df53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,7 +110,8 @@ def warn_deprecation_for_versions_less_than( | |
| dependent_distribution_package, | ||
| ) = _get_distribution_and_import_packages(dependent_import_package) | ||
| message_template = message_template or _flatten_message( | ||
| """DEPRECATION: Package {dependent_packages} depends on | ||
| """ | ||
| DEPRECATION: Package {dependent_packages} depends on | ||
| {dependency_packages}, currently installed at version | ||
| {version_used.__str__}. Future updates to | ||
| {dependent_packages} will require {dependency_packages} at | ||
|
|
@@ -120,12 +121,15 @@ def warn_deprecation_for_versions_less_than( | |
| {dependent_packages} can require the higher version, or | ||
| (b) you manually update your Python environment to use at | ||
| least version {next_supported_version} of | ||
| {dependency_packages}.""" | ||
| {dependency_packages}. | ||
| """ | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we make this into a constant? Maybe DEFAULT_PACKAGE_DEPRECATION_TEMPLATE? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer not to because the message template is defined and directly used in one place, and it's closely coupled to the variables provided by the function. I think black-boxing it inside the function, and defining it where it's used, is clearer and more compact than defining a separate constant inside or outside the function. |
||
| logging.warning( | ||
| message_template.format( | ||
| dependent_import_package=dependent_import_package, | ||
| dependency_import_package=dependency_import_package, | ||
| dependency_packages=dependency_packages, | ||
| dependent_packages=dependent_packages, | ||
| next_supported_version=next_supported_version, | ||
| version_used=version_used, | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,36 +185,42 @@ def min_python(date: datetime.date) -> str: | |
|
|
||
| if gapic_end < today: | ||
| message = _flatten_message( | ||
| f"""You are using a non-supported Python version | ||
| f""" | ||
| You are using a non-supported Python version | ||
| ({py_version_str}). Google will not post any further | ||
| updates to {package_label}. We suggest you upgrade to the | ||
| latest Python version, or at least Python | ||
| {min_python(today)}, and then update {package_label}. """ | ||
| {min_python(today)}, and then update {package_label}. | ||
| """ | ||
| ) | ||
| logging.warning(message) | ||
| return PythonVersionStatus.PYTHON_VERSION_UNSUPPORTED | ||
|
|
||
| eol_date = version_info.python_eol + EOL_GRACE_PERIOD | ||
| if eol_date <= today <= gapic_end: | ||
| message = _flatten_message( | ||
| f"""You are using a Python version ({py_version_str}) | ||
| f""" | ||
| You are using a Python version ({py_version_str}) | ||
| past its end of life. Google will update {package_label} | ||
| with critical bug fixes on a best-effort basis, but not | ||
| with any other fixes or features. We suggest you upgrade | ||
| to the latest Python version, or at least Python | ||
| {min_python(today)}, and then update {package_label}.""" | ||
| {min_python(today)}, and then update {package_label}. | ||
| """ | ||
| ) | ||
| logging.warning(message) | ||
| return PythonVersionStatus.PYTHON_VERSION_EOL | ||
|
|
||
| if gapic_deprecation <= today <= gapic_end: | ||
| message = _flatten_message( | ||
| f"""You are using a Python version ({py_version_str}), | ||
| f""" | ||
| You are using a Python version ({py_version_str}), | ||
| which Google will stop supporting in {package_label} when | ||
| it reaches its end of life ({version_info.python_eol}). We | ||
| suggest you upgrade to the latest Python version, or at | ||
| least Python {min_python(version_info.python_eol)}, and | ||
| then update {package_label}.""" | ||
| then update {package_label}. | ||
| """ | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think these message (or at least templates) would be better as constants, instead of embedded in the function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, for the same reason as the other case. They are defined and used directly only once, and the substitution strings and the text are closely related to the logic of the function. I think it reads more clearly to have them defined inline, as they are now. |
||
| logging.warning(message) | ||
| return PythonVersionStatus.PYTHON_VERSION_DEPRECATED | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these variables be made less similar? (dependent_x vs dependency_x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're the correct terms, but they are very similar. I changed the less common term (IMO),
dependent, toconsumer.