mirror of https://github.com/zulip/zulip.git
ruff: Fix FURB167 Use of regular expression alias.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
6a73006723
commit
5af8dfda3e
|
@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -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 [], ver
|
||||
numerals, 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 None
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -9,7 +9,7 @@ pattern = re.compile(
|
|||
(/ (?P<version> [^/ ]* ))?
|
||||
([ /] .*)?
|
||||
$""",
|
||||
re.X,
|
||||
re.VERBOSE,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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", [])
|
||||
]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue