jenkins-bot submitted this change.
[cleanup] Deprecate regex classes
DeprecatedRegex is completely unused (even by the deprecation helpers), and
the only spot that LazyRegex is used can just as easily compile in the normal
fashion.
Bug: T281200
Change-Id: Ia0f065ba063c1cdb0994d46d5b076bc0d43a999a
---
M pywikibot/tools/__init__.py
M pywikibot/tools/chars.py
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 33c764b..ebf28ff 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -1937,3 +1937,7 @@
replacement_name='types.MappingProxyType',
since='20210415',
future_warning=True)
+wrapper._add_deprecated_attr('LazyRegex', replacement_name='',
+ since='20210418', future_warning=True)
+wrapper._add_deprecated_attr('DeprecatedRegex', replacement_name='',
+ since='20210418', future_warning=True)
diff --git a/pywikibot/tools/chars.py b/pywikibot/tools/chars.py
index 945e70f..d7799a9 100644
--- a/pywikibot/tools/chars.py
+++ b/pywikibot/tools/chars.py
@@ -4,9 +4,9 @@
#
# Distributed under the terms of the MIT license.
#
+import re
import sys
-from pywikibot.tools import LazyRegex
from pywikibot.tools._unidata import _category_cf
@@ -14,7 +14,7 @@
# At the moment we've only added the characters from the Cf category
_invisible_chars = _category_cf
-invisible_regex = LazyRegex(lambda: '[{}]'.format(''.join(_invisible_chars)))
+INVISIBLE_REGEX = re.compile('[{}]'.format(''.join(_invisible_chars)))
def contains_invisible(text):
@@ -34,4 +34,5 @@
else:
codepoint = ord(match)
return '<{0:x}>'.format(codepoint)
- return invisible_regex.sub(replace, text)
+
+ return INVISIBLE_REGEX.sub(replace, text)
To view, visit change 681194. To unsubscribe, or for help writing mail filters, visit settings.