ruff: Fix B034 `re.split`, `re.sub` should pass keyword arguments.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-07-19 14:09:25 -07:00 committed by Tim Abbott
parent 50e6cba1af
commit d87eea1a67
4 changed files with 6 additions and 4 deletions

View File

@ -311,7 +311,7 @@ def filter_footer(text: str) -> str:
# isn't a trivial footer structure.
return text
return re.split(r"^\s*--\s*$", text, 1, flags=re.MULTILINE)[0].strip()
return re.split(r"^\s*--\s*$", text, maxsplit=1, flags=re.MULTILINE)[0].strip()
def extract_and_upload_attachments(message: EmailMessage, realm: Realm, sender: UserProfile) -> str:

View File

@ -33,7 +33,7 @@ def get_extra_data_from_widget_type(content: str, widget_type: Optional[str]) ->
for line in lines:
# If someone is using the list syntax, we remove it
# before adding an option.
option = re.sub(r"(\s*[-*]?\s*)", "", line.strip(), 1)
option = re.sub(r"(\s*[-*]?\s*)", "", line.strip(), count=1)
if len(option) > 0:
options.append(option)
extra_data = {

View File

@ -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("[.]+$", "", path_id_raw, re.M)
return re.sub("[.]+$", "", path_id_raw, flags=re.M)
def check_and_create_attachments(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:

View File

@ -89,7 +89,9 @@ def get_issue_created_event_body(payload: WildValue, include_title: bool) -> str
# Filter out multiline hidden comments
if description:
stringified_description = description.tame(check_string)
stringified_description = re.sub("<!--.*?-->", "", stringified_description, 0, re.DOTALL)
stringified_description = re.sub(
"<!--.*?-->", "", stringified_description, count=0, flags=re.DOTALL
)
stringified_description = stringified_description.rstrip()
else:
stringified_description = None