Skip to content

Commit 7e7fc8c

Browse files
committed
Just check the filename in the frame. Otherwise, it'll match on the current line.
1 parent 401c041 commit 7e7fc8c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

importlib_metadata/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ def _from_text_for(cls, text, dist):
196196
class Flake8Bypass(warnings.catch_warnings, contextlib.ContextDecorator):
197197
def __enter__(self):
198198
super().__enter__()
199-
is_flake8 = any('flake8' in str(frame) for frame in inspect.stack())
199+
is_flake8 = any(
200+
'flake8' in str(frame.filename) for frame in inspect.stack()[:5]
201+
)
200202
is_flake8 and warnings.simplefilter('ignore', DeprecationWarning)
201203

202204

@@ -219,7 +221,7 @@ class DeprecatedDict(dict):
219221
>>> list(dd.values())
220222
['bar']
221223
>>> len(recwarn)
222-
1
224+
2
223225
"""
224226

225227
_warn = functools.partial(

0 commit comments

Comments
 (0)