Fix syntaxWarning: invalid escape sequence '\s' (#16532)

Signed-off-by: Jie Fu <jiefu@tencent.com>
This commit is contained in:
Jie Fu (傅杰) 2025-04-12 22:39:42 +08:00 committed by GitHub
parent 3cdc57669f
commit 70363bccfa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1233,8 +1233,8 @@ class SortedHelpFormatter(ArgumentDefaultsHelpFormatter):
3. Each line is wrapped to the specified width (width of terminal). 3. Each line is wrapped to the specified width (width of terminal).
""" """
# The patterns also include whitespace after the newline # The patterns also include whitespace after the newline
single_newline = re.compile("(?<!\n)\n(?!\n)\s*") single_newline = re.compile(r"(?<!\n)\n(?!\n)\s*")
multiple_newlines = re.compile("\n{2,}\s*") multiple_newlines = re.compile(r"\n{2,}\s*")
text = single_newline.sub(' ', text) text = single_newline.sub(' ', text)
lines = re.split(multiple_newlines, text) lines = re.split(multiple_newlines, text)
return sum([textwrap.wrap(line, width) for line in lines], []) return sum([textwrap.wrap(line, width) for line in lines], [])