Skip to content

Commit 1f46354

Browse files
committed
Remove flake8 bypass and implement warning as a partial.
1 parent b022ae9 commit 1f46354

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

importlib_metadata/__init__.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import sys
66
import zipp
77
import email
8-
import inspect
98
import pathlib
109
import operator
1110
import warnings
@@ -228,23 +227,33 @@ def select(self, **params):
228227
return self._all.select(**params)
229228

230229

231-
class DeprecatedDict(dict): # pragma: nocover
230+
class DeprecatedDict(dict):
232231
"""
233232
Compatibility wrapper around dict to indicate that
234233
Mapping behavior is deprecated.
234+
235+
>>> recwarn = getfixture('recwarn')
236+
>>> dd = DeprecatedDict(foo='bar')
237+
>>> dd.get('baz', None)
238+
>>> dd['foo']
239+
'bar'
240+
>>> len(recwarn)
241+
1
235242
"""
236243

237-
def _warn(self):
238-
msg = "SelectableGroups dict interface is deprecated. Use select."
239-
warnings.warn(msg, DeprecationWarning, stacklevel=3)
244+
_warn = functools.partial(
245+
warnings.warn,
246+
"SelectableGroups dict interface is deprecated. Use select.",
247+
DeprecationWarning,
248+
stacklevel=3,
249+
)
240250

241251
def __getitem__(self, name):
242252
self._warn()
243253
return super().__getitem__(name)
244254

245255
def get(self, name, default=None):
246-
is_flake8 = any('flake8' in str(frame) for frame in inspect.stack())
247-
is_flake8 or self._warn()
256+
self._warn()
248257
return super().get(name, default)
249258

250259

0 commit comments

Comments
 (0)