From 032d63b97657d802362a707f57641ad702d5a0df Mon Sep 17 00:00:00 2001 From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Tue, 17 May 2022 12:56:24 -0400 Subject: [PATCH] Fix dummy creation script (#17304) --- utils/check_dummies.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/check_dummies.py b/utils/check_dummies.py index c1625036c4..d6c1c4b592 100644 --- a/utils/check_dummies.py +++ b/utils/check_dummies.py @@ -26,7 +26,7 @@ PATH_TO_TRANSFORMERS = "src/transformers" _re_backend = re.compile(r"is\_([a-z_]*)_available()") # Matches from xxx import bla _re_single_line_import = re.compile(r"\s+from\s+\S*\s+import\s+([^\(\s].*)\n") -_re_test_backend = re.compile(r"^\s+if\s+is\_[a-z]*\_available\(\)") +_re_test_backend = re.compile(r"^\s+if\s+not\s+is\_[a-z]*\_available\(\)") DUMMY_CONSTANT = """ @@ -73,6 +73,8 @@ def read_init(): # If the line is an if is_backend_available, we grab all objects associated. backend = find_backend(lines[line_index]) if backend is not None: + while not lines[line_index].startswith(" else:"): + line_index += 1 line_index += 1 objects = []