Skip to content

Fixed#2684: use the correct stacklevel for deprecation warnings #2689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

srinivasreddy
Copy link
Contributor

No description provided.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.805% when pulling 0387829 on srinivasreddy:2684 into 9b2753b on pytest-dev:master.

@@ -636,7 +636,7 @@ def __init__(self, *names, **attrs):
'pytest now uses argparse. "%default" should be'
' changed to "%(default)s" ',
DeprecationWarning,
stacklevel=3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change looks incorrect, the argument type is used indirectly and the higher level intended to trigger that warning for the method call side

@@ -919,7 +919,7 @@ def _idval(val, argname, idx, idfn, config=None):
import warnings
msg = "Raised while trying to determine id of parameter %s at position %d." % (argname, idx)
msg += '\nUpdate your code as this will raise an error in pytest-4.0.'
warnings.warn(msg, DeprecationWarning)
warnings.warn(msg, DeprecationWarning, stacklevel=2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this one stacklevel is actually not applicable

@@ -63,7 +63,7 @@ def extract_from(cls, parameterset, legacy_force_tuple=False):
argval = argval,

if newmarks:
warnings.warn(MARK_PARAMETERSET_UNPACKING)
warnings.warn(MARK_PARAMETERSET_UNPACKING, stacklevel=2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case stacklevel is also not usable, its a case where its probably more sensible to warn explicit and pass the test around

@RonnyPfannschmidt
Copy link
Member

i should have been more clear with what i meant by review, because simply setting stacklevel=2 everywhere is certainly incorrect

@nicoddemus
Copy link
Member

I agree, unfortunately a few of those will need to use warn_explicit because the origin of the warning is far away from the code that actually generates the warning.

@srinivasreddy
Copy link
Contributor Author

I am closing this.

@nicoddemus
Copy link
Member

Thanks anyway for the effort @srinivasreddy, we appreciate it! 👍

@srinivasreddy srinivasreddy deleted the 2684 branch August 16, 2017 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants