Pytest: Provide a way to suppress the new "deprecated python version" warning

Created on 31 Jan 2019  路  14Comments  路  Source: pytest-dev/pytest

Follow up to https://github.com/pytest-dev/pytest/issues/4627#issuecomment-459252679

How about a new ini option?

[pytest]
suppress_deprecated_python_warnings = 27 34

This allows one to selectively suppress the warning for some python versions. We will use this option in the future as well when we deprecate old Python versions.

cc @gaborbernat

enhancement proposal

Most helpful comment

@ssbarnea thanks for bringing that perspective up

in the aftermath i agree with @nicoddemus that its probably best not to show the warning at all

All 14 comments

How do we handle at the moment pypy, which still will be supported going ahead at interpreter level? E.g. do we also print a deprecation warning?

pypy 2.7 will be dropped as well, because we intend to use Python 3 features in the codebase.

I'd prefer to just document how to disable specific warnings by using the stdlib warnings module in conftest.py - that makes it easy to do conditional suppressions on any basis.

@Zac-HD in this instance this is not a normal warning, but implemented explicitly:

https://github.com/pytest-dev/pytest/blob/7dcd9bf5add337686ec6f2ee81b24e8424319dba/src/_pytest/terminal.py#L777-L789

I opted to implement it like this because I thought we wanted a very clear section separated from the rest of the other warnings. I have the impression that pip does the same thing because the message is shown during pip startup and doesn't look like it is formatted like a standard warning (didn't look deep into that though).

I see two options now:

  1. Change the warning to a normal warning; this allows users to use the standard warning filters. The disadvantage is that it might get "lost" amidst the other warnings.

  2. Implement a pytest.ini option like the one above to selectively disable the warning for specific Python versions.

Opinions?

I'd use a standard warning.

Not everyone will see it, but those who care to run -Werror either routinely or when preparing to upgrade will appreciate that it's a normal warning.

i was on the fence, but @Zac-HD has a good point - warning integration is critical

we could introduce a warning category where pytest doesn't consider it as a problem like it does with normal warnings (so tests go green)

we could introduce a warning category where pytest doesn't consider it as a problem like it does with normal warnings (so tests go green)

Not sure it buys us much, after all the user can configure pytest to ignore that warning altogether.

If nobody opposes this, we can then update the warning to a normal warning then in 4.3. 馃憤

:+1:

I've tried locally to use warnings, but the result was pretty ugly because it points to the pytest internals (where else?), and it broke a ton of tests across the test suite which will need fixing.

Should we still go on that road?

I still would - same arguments as above. However it might be worth expanding the warning message to include why this is happening and how to disable it. I'd also investigate whether the stacklevel= argument would be useful to skip some internal frames.

I see a trend in python community which reminds me of Windows Update annoyances or the EU cookie-gate: too much efforth spend force feeding the consumers and informing them about the future, assuming that they are are stupid or not informed enough. The famous pip version check would be another example but at least pip has the PIP_DISABLE_PIP_VERSION_CHECK=1 which can easily be added to tox.ini to silence it.

The result is pollution of almost every build log in the world. Yep, obviously that pip woudl not be the last version but WTH... I am sure neithers are the other 99.9% of the libraries used. What if glibc would start adding a stderr complaint on each call...

Should I also mention that pip displayed the py27 deprecation warnings on all py27 interpreters including pypy27 which is not scheduled for EOL on the same date. That's why I think that this approach is a waste of time as it is likely to create more annoyance, confusions and bugs than really fixing something.

I am perfectly normal to assume that a major new version could introduce issues like this and is up to the developer to assure he is using correct compatibility ranges in his reqs files.

@ssbarnea those are all good points.

How about if we remove the deprecation altogether? Python 2.7 users won't even mind this too much anyway given that pip won't install pytest 5.0 on Python 2.7 interpreters anyway.

@ssbarnea thanks for bringing that perspective up

in the aftermath i agree with @nicoddemus that its probably best not to show the warning at all

Opened https://github.com/pytest-dev/pytest/pull/4773 reverting the warning then. 馃憤

Was this page helpful?
0 / 5 - 0 ratings