`DeprecationWarning` for deprecated attributes should probably use stacklevel 2 · Issue #86 · pyasn1/pyasn1 · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
warnings.warn(f"{attr} is deprecated. Please use {newAttr} instead.", DeprecationWarning)
Currently the stack trace for these warnings will start at the definition site, when really they should start at the usage site. This would match the recommendation given in the warnings module and is also the stacklevel @warnings.deprecated uses by default for calling a deprecated function.
Pytest will only show the first stacklevel in its warnings summary by default and will be the main way people encounter these warnings, since they're off by default, so it's best for the first stack level to be indicative of where something needs to change in order for the warning to go away. It also makes it easier to filter the warning for specific third party packages that have yet still to make the transition, rather than ignoring the warning globally and risk regressions in your own code.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
E.g.
pyasn1/pyasn1/codec/ber/encoder.py
Line 952 in 0100d9a
Currently the stack trace for these warnings will start at the definition site, when really they should start at the usage site. This would match the recommendation given in the
warnings
module and is also the stacklevel@warnings.deprecated
uses by default for calling a deprecated function.Pytest will only show the first stacklevel in its warnings summary by default and will be the main way people encounter these warnings, since they're off by default, so it's best for the first stack level to be indicative of where something needs to change in order for the warning to go away. It also makes it easier to filter the warning for specific third party packages that have yet still to make the transition, rather than ignoring the warning globally and risk regressions in your own code.
The text was updated successfully, but these errors were encountered: