Skip to content

Commit

Permalink
chore: Add deprecation notice for 3.7. (#1371)
Browse files Browse the repository at this point in the history
  • Loading branch information
clundin25 authored Oct 23, 2023
1 parent d2ab3af commit 15f330e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
Python >= 3.7

**NOTE**:
Python 3.7 was marked as `unsupported`_ by the python community in June 2023.
We recommend that all developers upgrade to Python 3.8 and newer as soon as
they can. Support for Python 3.7 will be removed from this library after
January 1 2024. Previous releases that support Python 3.7 will continue to be available
for download, but releases after January 1 2024 will only target Python 3.8 and
newer.

.. _unsupported: https://devguide.python.org/versions/#unsupported-versions

Unsupported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Python == 2.7: The last version of this library with support for Python 2.7
Expand Down
25 changes: 25 additions & 0 deletions google/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"""Google Auth Library for Python."""

import logging
import sys
import warnings

from google.auth import version as google_auth_version
from google.auth._default import (
Expand All @@ -29,5 +31,28 @@

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


class Python37DeprecationWarning(DeprecationWarning): # pragma: NO COVER
"""
Deprecation warning raised when Python 3.7 runtime is detected.
Python 3.7 support will be dropped after January 1, 2024. See
https://cloud.google.com/python/docs/python37-sunset/ for more information.
"""

pass


# Checks if the current runtime is Python 3.7.
if sys.version_info.major == 3 and sys.version_info.minor == 7: # pragma: NO COVER
message = (
"After January 1, 2024, new releases of this library will drop support "
"for Python 3.7. More details about Python 3.7 support "
"can be found at https://cloud.google.com/python/docs/python37-sunset/"
)

# Configure the Python37DeprecationWarning warning so that it is only emitted once.
warnings.simplefilter("once", Python37DeprecationWarning)
warnings.warn(message, Python37DeprecationWarning)

# Set default logging handler to avoid "No handler found" warnings.
logging.getLogger(__name__).addHandler(logging.NullHandler())
25 changes: 25 additions & 0 deletions google/oauth2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,28 @@
# limitations under the License.

"""Google OAuth 2.0 Library for Python."""

import sys
import warnings


class Python37DeprecationWarning(DeprecationWarning): # pragma: NO COVER
"""
Deprecation warning raised when Python 3.7 runtime is detected.
Python 3.7 support will be dropped after January 1, 2024. See
https://cloud.google.com/python/docs/python37-sunset/ for more information.
"""

pass


# Checks if the current runtime is Python 3.7.
if sys.version_info.major == 3 and sys.version_info.minor == 7: # pragma: NO COVER
message = (
"After January 1, 2024, new releases of this library will drop support "
"for Python 3.7. More details about Python 3.7 support "
"can be found at https://cloud.google.com/python/docs/python37-sunset/"
)
# Configure the Python37DeprecationWarning warning so that it is only emitted once.
warnings.simplefilter("once", Python37DeprecationWarning)
warnings.warn(message, Python37DeprecationWarning)
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.

0 comments on commit 15f330e

Please sign in to comment.