Skip to content

Commit

Permalink
Use @deprecated for Registry.add()
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-six committed May 16, 2022
1 parent 9d90d47 commit 0394b26
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions markdown/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ def __delitem__(self, key):
else:
raise KeyError('Cannot delete key {}, not registered.'.format(key))

@deprecated('Use the `register` method instead.')
def add(self, key, value, location):
""" Register a key by location. """
if len(self) == 0:
Expand Down Expand Up @@ -459,12 +460,6 @@ def add(self, key, value, location):
raise ValueError('Not a valid location: "%s". Location key '
'must start with a ">" or "<".' % 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,
stacklevel=2,
)


def __getattr__(name):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def testRegistryDeprecatedAdd(self):
r.add('f', Item('f'), 'badlocation')

# Check the warnings
self.assertEqual(len(w), 7)
self.assertEqual(len(w), 8)
self.assertTrue(all(issubclass(x.category, DeprecationWarning) for x in w))


Expand Down

0 comments on commit 0394b26

Please sign in to comment.