prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  deprecation notice for 3.7 modifies global state (user warning filters) as import side-effect
  It is impossible to filter Python37DeprecationWarning after PR https://github.com/googleapis/google-auth-library-python/pull/1371.
  
  Custom libraries should not configure warning filters, because it is user project's global state. Most of the times you cannot modify import order and insert new warning filters after your library modifies them.
  
  #### Environment details
  
    - OS: Ubuntu 22.04.3 LTS linux 5.15.0-89-generic
    - Python version: 3.7.17
    - pip version: 23.3.1
    - `google-auth` version: 2.24.0
  
  #### Steps to reproduce
  
    1. install google-auth into your python3.7 project
    2. configure filterwarning rule `ignore::DeprecationWarning` in pytest.ini
    3. use google.auth or google.oauth2 somewhere in your project
    4. run pytest
    5. get Python37DeprecationWarning that you cannot filter 
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `google/oauth2/__init__.py`
  Content:
  ```
  1 # Copyright 2016 Google LLC
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #      http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 """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)
  41
  ```
  
  Path: `google/auth/__init__.py`
  Content:
  ```
  1 # Copyright 2016 Google LLC
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #      http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 """Google Auth Library for Python."""
  16 
  17 import logging
  18 import sys
  19 import warnings
  20 
  21 from google.auth import version as google_auth_version
  22 from google.auth._default import (
  23     default,
  24     load_credentials_from_dict,
  25     load_credentials_from_file,
  26 )
  27 
  28 
  29 __version__ = google_auth_version.__version__
  30 
  31 
  32 __all__ = ["default", "load_credentials_from_file", "load_credentials_from_dict"]
  33 
  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 
  57 # Set default logging handler to avoid "No handler found" warnings.
  58 logging.getLogger(__name__).addHandler(logging.NullHandler())
  59
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/google/auth/__init__.py b/google/auth/__init__.py
  --- a/google/auth/__init__.py
  +++ b/google/auth/__init__.py
  @@ -49,9 +49,6 @@
           "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.
  diff --git a/google/oauth2/__init__.py b/google/oauth2/__init__.py
  --- a/google/oauth2/__init__.py
  +++ b/google/oauth2/__init__.py
  @@ -35,6 +35,4 @@
           "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)
  
verification_info: {"golden_diff": "diff --git a/google/auth/__init__.py b/google/auth/__init__.py\n--- a/google/auth/__init__.py\n+++ b/google/auth/__init__.py\n@@ -49,9 +49,6 @@\n         \"for Python 3.7. More details about Python 3.7 support \"\n         \"can be found at https://cloud.google.com/python/docs/python37-sunset/\"\n     )\n-\n-    # Configure the Python37DeprecationWarning warning so that it is only emitted once.\n-    warnings.simplefilter(\"once\", Python37DeprecationWarning)\n     warnings.warn(message, Python37DeprecationWarning)\n \n # Set default logging handler to avoid \"No handler found\" warnings.\ndiff --git a/google/oauth2/__init__.py b/google/oauth2/__init__.py\n--- a/google/oauth2/__init__.py\n+++ b/google/oauth2/__init__.py\n@@ -35,6 +35,4 @@\n         \"for Python 3.7. More details about Python 3.7 support \"\n         \"can be found at https://cloud.google.com/python/docs/python37-sunset/\"\n     )\n-    # Configure the Python37DeprecationWarning warning so that it is only emitted once.\n-    warnings.simplefilter(\"once\", Python37DeprecationWarning)\n     warnings.warn(message, Python37DeprecationWarning)\n", "issue": "deprecation notice for 3.7 modifies global state (user warning filters) as import side-effect\nIt is impossible to filter Python37DeprecationWarning after PR https://github.com/googleapis/google-auth-library-python/pull/1371.\r\n\r\nCustom libraries should not configure warning filters, because it is user project's global state. Most of the times you cannot modify import order and insert new warning filters after your library modifies them.\r\n\r\n#### Environment details\r\n\r\n  - OS: Ubuntu 22.04.3 LTS linux 5.15.0-89-generic\r\n  - Python version: 3.7.17\r\n  - pip version: 23.3.1\r\n  - `google-auth` version: 2.24.0\r\n\r\n#### Steps to reproduce\r\n\r\n  1. install google-auth into your python3.7 project\r\n  2. configure filterwarning rule `ignore::DeprecationWarning` in pytest.ini\r\n  3. use google.auth or google.oauth2 somewhere in your project\r\n  4. run pytest\r\n  5. get Python37DeprecationWarning that you cannot filter \n", "before_files": [{"content": "# Copyright 2016 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Google OAuth 2.0 Library for Python.\"\"\"\n\nimport sys\nimport warnings\n\n\nclass Python37DeprecationWarning(DeprecationWarning):  # pragma: NO COVER\n    \"\"\"\n    Deprecation warning raised when Python 3.7 runtime is detected.\n    Python 3.7 support will be dropped after January 1, 2024. See\n    https://cloud.google.com/python/docs/python37-sunset/ for more information.\n    \"\"\"\n\n    pass\n\n\n# Checks if the current runtime is Python 3.7.\nif sys.version_info.major == 3 and sys.version_info.minor == 7:  # pragma: NO COVER\n    message = (\n        \"After January 1, 2024, new releases of this library will drop support \"\n        \"for Python 3.7. More details about Python 3.7 support \"\n        \"can be found at https://cloud.google.com/python/docs/python37-sunset/\"\n    )\n    # Configure the Python37DeprecationWarning warning so that it is only emitted once.\n    warnings.simplefilter(\"once\", Python37DeprecationWarning)\n    warnings.warn(message, Python37DeprecationWarning)\n", "path": "google/oauth2/__init__.py"}, {"content": "# Copyright 2016 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Google Auth Library for Python.\"\"\"\n\nimport logging\nimport sys\nimport warnings\n\nfrom google.auth import version as google_auth_version\nfrom google.auth._default import (\n    default,\n    load_credentials_from_dict,\n    load_credentials_from_file,\n)\n\n\n__version__ = google_auth_version.__version__\n\n\n__all__ = [\"default\", \"load_credentials_from_file\", \"load_credentials_from_dict\"]\n\n\nclass Python37DeprecationWarning(DeprecationWarning):  # pragma: NO COVER\n    \"\"\"\n    Deprecation warning raised when Python 3.7 runtime is detected.\n    Python 3.7 support will be dropped after January 1, 2024. See\n    https://cloud.google.com/python/docs/python37-sunset/ for more information.\n    \"\"\"\n\n    pass\n\n\n# Checks if the current runtime is Python 3.7.\nif sys.version_info.major == 3 and sys.version_info.minor == 7:  # pragma: NO COVER\n    message = (\n        \"After January 1, 2024, new releases of this library will drop support \"\n        \"for Python 3.7. More details about Python 3.7 support \"\n        \"can be found at https://cloud.google.com/python/docs/python37-sunset/\"\n    )\n\n    # Configure the Python37DeprecationWarning warning so that it is only emitted once.\n    warnings.simplefilter(\"once\", Python37DeprecationWarning)\n    warnings.warn(message, Python37DeprecationWarning)\n\n# Set default logging handler to avoid \"No handler found\" warnings.\nlogging.getLogger(__name__).addHandler(logging.NullHandler())\n", "path": "google/auth/__init__.py"}], "after_files": [{"content": "# Copyright 2016 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Google OAuth 2.0 Library for Python.\"\"\"\n\nimport sys\nimport warnings\n\n\nclass Python37DeprecationWarning(DeprecationWarning):  # pragma: NO COVER\n    \"\"\"\n    Deprecation warning raised when Python 3.7 runtime is detected.\n    Python 3.7 support will be dropped after January 1, 2024. See\n    https://cloud.google.com/python/docs/python37-sunset/ for more information.\n    \"\"\"\n\n    pass\n\n\n# Checks if the current runtime is Python 3.7.\nif sys.version_info.major == 3 and sys.version_info.minor == 7:  # pragma: NO COVER\n    message = (\n        \"After January 1, 2024, new releases of this library will drop support \"\n        \"for Python 3.7. More details about Python 3.7 support \"\n        \"can be found at https://cloud.google.com/python/docs/python37-sunset/\"\n    )\n    warnings.warn(message, Python37DeprecationWarning)\n", "path": "google/oauth2/__init__.py"}, {"content": "# Copyright 2016 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Google Auth Library for Python.\"\"\"\n\nimport logging\nimport sys\nimport warnings\n\nfrom google.auth import version as google_auth_version\nfrom google.auth._default import (\n    default,\n    load_credentials_from_dict,\n    load_credentials_from_file,\n)\n\n\n__version__ = google_auth_version.__version__\n\n\n__all__ = [\"default\", \"load_credentials_from_file\", \"load_credentials_from_dict\"]\n\n\nclass Python37DeprecationWarning(DeprecationWarning):  # pragma: NO COVER\n    \"\"\"\n    Deprecation warning raised when Python 3.7 runtime is detected.\n    Python 3.7 support will be dropped after January 1, 2024. See\n    https://cloud.google.com/python/docs/python37-sunset/ for more information.\n    \"\"\"\n\n    pass\n\n\n# Checks if the current runtime is Python 3.7.\nif sys.version_info.major == 3 and sys.version_info.minor == 7:  # pragma: NO COVER\n    message = (\n        \"After January 1, 2024, new releases of this library will drop support \"\n        \"for Python 3.7. More details about Python 3.7 support \"\n        \"can be found at https://cloud.google.com/python/docs/python37-sunset/\"\n    )\n    warnings.warn(message, Python37DeprecationWarning)\n\n# Set default logging handler to avoid \"No handler found\" warnings.\nlogging.getLogger(__name__).addHandler(logging.NullHandler())\n", "path": "google/auth/__init__.py"}]}