Skip to content

Commit 15f330e

Browse files
authored
chore: Add deprecation notice for 3.7. (#1371)
1 parent d2ab3af commit 15f330e

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ Supported Python Versions
3737
^^^^^^^^^^^^^^^^^^^^^^^^^
3838
Python >= 3.7
3939

40+
**NOTE**:
41+
Python 3.7 was marked as `unsupported`_ by the python community in June 2023.
42+
We recommend that all developers upgrade to Python 3.8 and newer as soon as
43+
they can. Support for Python 3.7 will be removed from this library after
44+
January 1 2024. Previous releases that support Python 3.7 will continue to be available
45+
for download, but releases after January 1 2024 will only target Python 3.8 and
46+
newer.
47+
48+
.. _unsupported: https://devguide.python.org/versions/#unsupported-versions
49+
4050
Unsupported Python Versions
4151
^^^^^^^^^^^^^^^^^^^^^^^^^^^
4252
- Python == 2.7: The last version of this library with support for Python 2.7

google/auth/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"""Google Auth Library for Python."""
1616

1717
import logging
18+
import sys
19+
import warnings
1820

1921
from google.auth import version as google_auth_version
2022
from google.auth._default import (
@@ -29,5 +31,28 @@
2931

3032
__all__ = ["default", "load_credentials_from_file", "load_credentials_from_dict"]
3133

34+
35+
class Python37DeprecationWarning(DeprecationWarning): # pragma: NO COVER
36+
"""
37+
Deprecation warning raised when Python 3.7 runtime is detected.
38+
Python 3.7 support will be dropped after January 1, 2024. See
39+
https://cloud.google.com/python/docs/python37-sunset/ for more information.
40+
"""
41+
42+
pass
43+
44+
45+
# Checks if the current runtime is Python 3.7.
46+
if sys.version_info.major == 3 and sys.version_info.minor == 7: # pragma: NO COVER
47+
message = (
48+
"After January 1, 2024, new releases of this library will drop support "
49+
"for Python 3.7. More details about Python 3.7 support "
50+
"can be found at https://cloud.google.com/python/docs/python37-sunset/"
51+
)
52+
53+
# Configure the Python37DeprecationWarning warning so that it is only emitted once.
54+
warnings.simplefilter("once", Python37DeprecationWarning)
55+
warnings.warn(message, Python37DeprecationWarning)
56+
3257
# Set default logging handler to avoid "No handler found" warnings.
3358
logging.getLogger(__name__).addHandler(logging.NullHandler())

google/oauth2/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,28 @@
1313
# limitations under the License.
1414

1515
"""Google OAuth 2.0 Library for Python."""
16+
17+
import sys
18+
import warnings
19+
20+
21+
class Python37DeprecationWarning(DeprecationWarning): # pragma: NO COVER
22+
"""
23+
Deprecation warning raised when Python 3.7 runtime is detected.
24+
Python 3.7 support will be dropped after January 1, 2024. See
25+
https://cloud.google.com/python/docs/python37-sunset/ for more information.
26+
"""
27+
28+
pass
29+
30+
31+
# Checks if the current runtime is Python 3.7.
32+
if sys.version_info.major == 3 and sys.version_info.minor == 7: # pragma: NO COVER
33+
message = (
34+
"After January 1, 2024, new releases of this library will drop support "
35+
"for Python 3.7. More details about Python 3.7 support "
36+
"can be found at https://cloud.google.com/python/docs/python37-sunset/"
37+
)
38+
# Configure the Python37DeprecationWarning warning so that it is only emitted once.
39+
warnings.simplefilter("once", Python37DeprecationWarning)
40+
warnings.warn(message, Python37DeprecationWarning)

system_tests/secrets.tar.enc

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)