"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "d863e7e60b063936ad25b26ab1bc473f334cfcfb"
Unverified Commit 54272503 authored by Lingepumpe's avatar Lingepumpe Committed by GitHub
Browse files

Avoid invalid escape sequences, use raw strings (#22936)

* Avoid invalid escape sequences, use raw strings

* Integrate PR feedback
parent 81c1910c
...@@ -35,9 +35,9 @@ _re_import_struct_add_one = re.compile(r'^\s*_import_structure\["\S*"\]\.append\ ...@@ -35,9 +35,9 @@ _re_import_struct_add_one = re.compile(r'^\s*_import_structure\["\S*"\]\.append\
# Catches a line _import_struct["bla"].extend(["foo", "bar"]) or _import_struct["bla"] = ["foo", "bar"] # Catches a line _import_struct["bla"].extend(["foo", "bar"]) or _import_struct["bla"] = ["foo", "bar"]
_re_import_struct_add_many = re.compile(r"^\s*_import_structure\[\S*\](?:\.extend\(|\s*=\s+)\[([^\]]*)\]") _re_import_struct_add_many = re.compile(r"^\s*_import_structure\[\S*\](?:\.extend\(|\s*=\s+)\[([^\]]*)\]")
# Catches a line with an object between quotes and a comma: "MyModel", # Catches a line with an object between quotes and a comma: "MyModel",
_re_quote_object = re.compile('^\s+"([^"]+)",') _re_quote_object = re.compile(r'^\s+"([^"]+)",')
# Catches a line with objects between brackets only: ["foo", "bar"], # Catches a line with objects between brackets only: ["foo", "bar"],
_re_between_brackets = re.compile("^\s+\[([^\]]+)\]") _re_between_brackets = re.compile(r"^\s+\[([^\]]+)\]")
# Catches a line with from foo import bar, bla, boo # Catches a line with from foo import bar, bla, boo
_re_import = re.compile(r"\s+from\s+\S*\s+import\s+([^\(\s].*)\n") _re_import = re.compile(r"\s+from\s+\S*\s+import\s+([^\(\s].*)\n")
# Catches a line with try: # Catches a line with try:
...@@ -78,7 +78,7 @@ def parse_init(init_file): ...@@ -78,7 +78,7 @@ def parse_init(init_file):
# If we have everything on a single line, let's deal with it. # If we have everything on a single line, let's deal with it.
if _re_one_line_import_struct.search(line): if _re_one_line_import_struct.search(line):
content = _re_one_line_import_struct.search(line).groups()[0] content = _re_one_line_import_struct.search(line).groups()[0]
imports = re.findall("\[([^\]]+)\]", content) imports = re.findall(r"\[([^\]]+)\]", content)
for imp in imports: for imp in imports:
objects.extend([obj[1:-1] for obj in imp.split(", ")]) objects.extend([obj[1:-1] for obj in imp.split(", ")])
line_index += 1 line_index += 1
......
...@@ -755,7 +755,7 @@ def find_all_documented_objects(): ...@@ -755,7 +755,7 @@ def find_all_documented_objects():
for doc_file in Path(PATH_TO_DOC).glob("**/*.mdx"): for doc_file in Path(PATH_TO_DOC).glob("**/*.mdx"):
with open(doc_file, "r", encoding="utf-8", newline="\n") as f: with open(doc_file, "r", encoding="utf-8", newline="\n") as f:
content = f.read() content = f.read()
raw_doc_objs = re.findall("\[\[autodoc\]\]\s+(\S+)\s+", content) raw_doc_objs = re.findall(r"\[\[autodoc\]\]\s+(\S+)\s+", content)
documented_obj += [obj.split(".")[-1] for obj in raw_doc_objs] documented_obj += [obj.split(".")[-1] for obj in raw_doc_objs]
return documented_obj return documented_obj
......
...@@ -52,7 +52,7 @@ def extract_first_line_failure(failures_short_lines): ...@@ -52,7 +52,7 @@ def extract_first_line_failure(failures_short_lines):
file = None file = None
in_error = False in_error = False
for line in failures_short_lines.split("\n"): for line in failures_short_lines.split("\n"):
if re.search("_ \[doctest\]", line): if re.search(r"_ \[doctest\]", line):
in_error = True in_error = True
file = line.split(" ")[2] file = line.split(" ")[2]
elif in_error and not line.split(" ")[0].isdigit(): elif in_error and not line.split(" ")[0].isdigit():
......
...@@ -23,7 +23,7 @@ PATH_TO_AUTO_MODULE = "src/transformers/models/auto" ...@@ -23,7 +23,7 @@ PATH_TO_AUTO_MODULE = "src/transformers/models/auto"
# re pattern that matches mapping introductions: # re pattern that matches mapping introductions:
# SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict
_re_intro_mapping = re.compile("[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedDict") _re_intro_mapping = re.compile(r"[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedDict")
# re pattern that matches identifiers in mappings # re pattern that matches identifiers in mappings
_re_identifier = re.compile(r'\s*\(\s*"(\S[^"]+)"') _re_identifier = re.compile(r'\s*\(\s*"(\S[^"]+)"')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment