diff options
author | L <leven.cn@gmail.com> | 2022-05-17 02:23:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 14:23:01 -0400 |
commit | 0394b26c61014feea4d5be4f543f2caa7f058b0b (patch) | |
tree | 74200f89003c1f502d8a8ef026526f6ea1fff456 | |
parent | 9d90d47157f4348ad70f1a070571de87efbc6cbc (diff) | |
download | python-markdown-0394b26c61014feea4d5be4f543f2caa7f058b0b.tar.gz |
Use `@deprecated` for Registry.add()
-rw-r--r-- | markdown/util.py | 7 | ||||
-rw-r--r-- | 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)) |