From 0394b26c61014feea4d5be4f543f2caa7f058b0b Mon Sep 17 00:00:00 2001 From: L Date: Tue, 17 May 2022 02:23:01 +0800 Subject: Use `@deprecated` for Registry.add() --- markdown/util.py | 7 +------ tests/test_apis.py | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/markdown/util.py b/markdown/util.py index 46cfe68..c31f6e2 100644 --- a/markdown/util.py +++ b/markdown/util.py @@ -423,6 +423,7 @@ class Registry: 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: @@ -459,12 +460,6 @@ class Registry: 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): diff --git a/tests/test_apis.py b/tests/test_apis.py index 16f3088..c977e6b 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -420,7 +420,7 @@ class RegistryTests(unittest.TestCase): 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)) -- cgit v1.2.1