Adjust stacklevel of implprefix warning#181
Adjust stacklevel of implprefix warning#181goodboy merged 1 commit intopytest-dev:masterfrom crazymerlyn:change_implprefix_warning_stacklevel
Conversation
|
The build is failing due to a recent change in pytest which adds a wrapper for |
|
@crazymerlyn thanks for the PR 👍! |
Oh indeed, good catch. What do you think @asottile? |
oh! I see what you're saying now -- I was wracking my brain to figure out what was meant here. if isinstance(kwargs.get('stacklevel'), int):
kwargs['stacklevel'] += 1might be safer probably PR that to pytest and we can get it into 3.9.2? |
Yeah, that seems better. But while we are on this, I think stacklevel also needs to be changed if it is not present in kwargs. The default value is 1. So, if somebody uses recwarn in python2.7, the warning will present itself at the wrapper function rather than the line causing the warning. if isinstance(kwargs.get('stacklevel'), int):
kwargs['stacklevel'] += 1
elif 'stacklevel' not in kwargs:
kwargs['stacklevel'] = 2 |
|
ah in that case even easier: kwargs.setdefault('stacklevel', 1)
kwargs['stacklevel'] += 1 |
|
So, I tried adding this change to a PR but got a few errors with |
|
hmm yeah this is probably the |
Heh, that's all good and part of the game 😁 |
|
not pretty, but at least this is throwaway :'( pytest-dev/pytest#4192 |
|
sorry about the trouble again, thanks for the report! 🎉 |
|
@nicoddemus good to go here yah? |
|
yah! |
|
Many thanks! |
Fixes #166.