Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
ruff: Fix FURB167 Use of regular expression alias.
Anders Kaseorg5af8dfda3edd
diff --git a/scripts/log-search b/scripts/log-searchindex 2e52a8c4be0..0bc488d29c5 100755--- a/scripts/log-search+++ b/scripts/log-search@@ -147,7 +147,7 @@ NGINX_LOG_LINE_RE = re.compile((?P<hostname> \S+ ) \s+(?P<duration> \S+ )""",- re.X,+ re.VERBOSE,)PYTHON_LOG_LINE_RE = re.compile(@@ -178,7 +178,7 @@ PYTHON_LOG_LINE_RE = re.compile() \s+ via \s+ (?P<user_agent> .* )\)""",- re.X,+ re.VERBOSE,)diff --git a/zerver/lib/compatibility.py b/zerver/lib/compatibility.pyindex 912345454ad..1c237cc91e9 100644--- a/zerver/lib/compatibility.py+++ b/zerver/lib/compatibility.py@@ -43,7 +43,7 @@ def is_outdated_server(user_profile: Optional[UserProfile]) -> bool:def pop_numerals(ver: str) -> Tuple[List[int], str]:- match = re.search(r"^( \d+ (?: \. \d+ )* ) (.*)", ver, re.X)+ match = re.search(r"^( \d+ (?: \. \d+ )* ) (.*)", ver, re.VERBOSE)if match is None:return [], vernumerals, rest = match.groups()@@ -94,9 +94,9 @@ def version_lt(ver1: str, ver2: str) -> Optional[bool]:def find_mobile_os(user_agent: str) -> Optional[str]:- if re.search(r"\b Android \b", user_agent, re.I | re.X):+ if re.search(r"\b Android \b", user_agent, re.IGNORECASE | re.VERBOSE):return "android"- if re.search(r"\b(?: iOS | iPhone\ OS )\b", user_agent, re.I | re.X):+ if re.search(r"\b(?: iOS | iPhone\ OS )\b", user_agent, re.IGNORECASE | re.VERBOSE):return "ios"return Nonediff --git a/zerver/lib/markdown/include.py b/zerver/lib/markdown/include.pyindex 394181064e0..b5bf68b162c 100644--- a/zerver/lib/markdown/include.py+++ b/zerver/lib/markdown/include.py@@ -27,7 +27,7 @@ class IncludeExtension(Extension):class IncludeBlockProcessor(BlockProcessor):- RE = re.compile(r"^ {,3}\{!([^!]+)!\} *$", re.M)+ RE = re.compile(r"^ {,3}\{!([^!]+)!\} *$", re.MULTILINE)def __init__(self, parser: BlockParser, base_path: str) -> None:super().__init__(parser)diff --git a/zerver/lib/user_agent.py b/zerver/lib/user_agent.pyindex b80dc15dfcd..28ec2720d45 100644--- a/zerver/lib/user_agent.py+++ b/zerver/lib/user_agent.py@@ -9,7 +9,7 @@ pattern = re.compile((/ (?P<version> [^/ ]* ))?([ /] .*)?$""",- re.X,+ re.VERBOSE,)diff --git a/zerver/migrations/0041_create_attachments_for_old_messages.py b/zerver/migrations/0041_create_attachments_for_old_messages.pyindex 6b8d593a193..838a21be8f4 100644--- a/zerver/migrations/0041_create_attachments_for_old_messages.py+++ b/zerver/migrations/0041_create_attachments_for_old_messages.py@@ -11,7 +11,7 @@ attachment_url_re = re.compile(r"[/\-]user[\-_]uploads[/\.-].*?(?=[ )]|\Z)")def attachment_url_to_path_id(attachment_url: str) -> str:path_id_raw = re.sub(r"[/\-]user[\-_]uploads[/\.-]", "", attachment_url)# Remove any extra '.' after file extension. These are probably added by the user- return re.sub(r"[.]+$", "", path_id_raw, flags=re.M)+ return re.sub(r"[.]+$", "", path_id_raw, flags=re.MULTILINE)def check_and_create_attachments(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:diff --git a/zerver/openapi/markdown_extension.py b/zerver/openapi/markdown_extension.pyindex d5310c8d069..1cac2098853 100644--- a/zerver/openapi/markdown_extension.py+++ b/zerver/openapi/markdown_extension.py@@ -170,7 +170,7 @@ def render_javascript_code_example() -> List[str]:pattern = rf'^add_example\(\s*"[^"]*",\s*{re.escape(json.dumps(function))},\s*\d+,\s*async \(client, console\) => \{{\n(.*?)^(?:\}}| *\}},\n)\);$'with open("zerver/openapi/javascript_examples.js") as f:- m = re.search(pattern, f.read(), re.M | re.S)+ m = re.search(pattern, f.read(), re.MULTILINE | re.DOTALL)if m is None:return []function_source_lines = dedent(m.group(1)).splitlines()diff --git a/zerver/tornado/sharding.py b/zerver/tornado/sharding.pyindex f12b571d92e..f876e06d9cf 100644--- a/zerver/tornado/sharding.py+++ b/zerver/tornado/sharding.py@@ -17,7 +17,8 @@ if os.path.exists("/etc/zulip/sharding.json"):data, # backwards compatibility)shard_regexes = [- (re.compile(regex, re.I), port) for regex, port in data.get("shard_regexes", [])+ (re.compile(regex, re.IGNORECASE), port)+ for regex, port in data.get("shard_regexes", [])]