Fix backend regex (#14566)

This commit is contained in:
Sylvain Gugger
2021-11-30 05:32:20 -05:00
committed by GitHub
parent c468a87a69
commit 254fef67cf

View File

@@ -22,11 +22,11 @@ PATH_TO_TRANSFORMERS = "src/transformers"
# Matches is_xxx_available() # Matches is_xxx_available()
_re_backend = re.compile(r"is\_([a-z]*)_available()") _re_backend = re.compile(r"is\_([a-z_]*)_available()")
# Catches a line with a key-values pattern: "bla": ["foo", "bar"] # Catches a line with a key-values pattern: "bla": ["foo", "bar"]
_re_import_struct_key_value = re.compile(r'\s+"\S*":\s+\[([^\]]*)\]') _re_import_struct_key_value = re.compile(r'\s+"\S*":\s+\[([^\]]*)\]')
# Catches a line if is_foo_available # Catches a line if is_foo_available
_re_test_backend = re.compile(r"^\s*if\s+is\_[a-z]*\_available\(\)") _re_test_backend = re.compile(r"^\s*if\s+is\_[a-z_]*\_available\(\)")
# Catches a line _import_struct["bla"].append("foo") # Catches a line _import_struct["bla"].append("foo")
_re_import_struct_add_one = re.compile(r'^\s*_import_structure\["\S*"\]\.append\("(\S*)"\)') _re_import_struct_add_one = re.compile(r'^\s*_import_structure\["\S*"\]\.append\("(\S*)"\)')
# 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"]