googleapis / google-auth-library-python

Google Auth Python Library
https://googleapis.dev/python/google-auth/latest/
Apache License 2.0
771 stars 304 forks source link

deprecation notice for 3.7 modifies global state (user warning filters) as import side-effect #1427

Closed artgromov closed 8 months ago

artgromov commented 8 months ago

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

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
parthea commented 8 months ago

Hi @artgromov!

Thanks for reporting this issue. It will be fixed in #1428.

Here is the pytest.ini that I used for testing

[pytest]
filterwarnings =
    # treat all warnings as errors
    error
    ignore:After January 1, 2024, new releases of this library will drop support for Python 3.7:DeprecationWarning