Skip to content

Commit

Permalink
add: use stacklevel=2 with warning
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed authored and waylan committed Nov 14, 2018
1 parent daf9e6d commit 0c7924e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions markdown/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,9 @@ def __setitem__(self, key, value):
if isinstance(key, string_type):
warnings.warn(
'Using setitem to register a processor or pattern is deprecated. '
'Use the `register` method instead.', DeprecationWarning
'Use the `register` method instead.',
DeprecationWarning,
stacklevel=2,
)
if key in self:
# Key already exists, replace without altering priority
Expand All @@ -445,7 +447,9 @@ def __delitem__(self, key):
self.deregister(key)
warnings.warn(
'Using del to remove a processor or pattern is deprecated. '
'Use the `deregister` method instead.', DeprecationWarning
'Use the `deregister` method instead.',
DeprecationWarning,
stacklevel=2,
)
else:
raise TypeError
Expand Down Expand Up @@ -488,5 +492,7 @@ def add(self, key, value, location):
self.register(value, key, priority)
warnings.warn(
'Using the add method to register a processor or pattern is deprecated. '
'Use the `register` method instead.', DeprecationWarning
'Use the `register` method instead.',
DeprecationWarning,
stacklevel=2,
)

0 comments on commit 0c7924e

Please sign in to comment.