Skip to content

Commit

Permalink
Just check the filename in the frame. Otherwise, it'll match on the c…
Browse files Browse the repository at this point in the history
…urrent line.
  • Loading branch information
jaraco committed Mar 4, 2021
1 parent 401c041 commit 7e7fc8c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ def _from_text_for(cls, text, dist):
class Flake8Bypass(warnings.catch_warnings, contextlib.ContextDecorator):
def __enter__(self):
super().__enter__()
is_flake8 = any('flake8' in str(frame) for frame in inspect.stack())
is_flake8 = any(
'flake8' in str(frame.filename) for frame in inspect.stack()[:5]
)
is_flake8 and warnings.simplefilter('ignore', DeprecationWarning)


Expand All @@ -219,7 +221,7 @@ class DeprecatedDict(dict):
>>> list(dd.values())
['bar']
>>> len(recwarn)
1
2
"""

_warn = functools.partial(
Expand Down

0 comments on commit 7e7fc8c

Please sign in to comment.