Check copies match full class/function names (#10030)
This commit is contained in:
@@ -36,6 +36,7 @@ def find_code_in_transformers(object_name):
|
|||||||
module = parts[i]
|
module = parts[i]
|
||||||
while i < len(parts) and not os.path.isfile(os.path.join(TRANSFORMERS_PATH, f"{module}.py")):
|
while i < len(parts) and not os.path.isfile(os.path.join(TRANSFORMERS_PATH, f"{module}.py")):
|
||||||
i += 1
|
i += 1
|
||||||
|
if i < len(parts):
|
||||||
module = os.path.join(module, parts[i])
|
module = os.path.join(module, parts[i])
|
||||||
if i >= len(parts):
|
if i >= len(parts):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
@@ -49,7 +50,9 @@ def find_code_in_transformers(object_name):
|
|||||||
indent = ""
|
indent = ""
|
||||||
line_index = 0
|
line_index = 0
|
||||||
for name in parts[i + 1 :]:
|
for name in parts[i + 1 :]:
|
||||||
while line_index < len(lines) and re.search(fr"^{indent}(class|def)\s+{name}", lines[line_index]) is None:
|
while (
|
||||||
|
line_index < len(lines) and re.search(fr"^{indent}(class|def)\s+{name}(\(|\:)", lines[line_index]) is None
|
||||||
|
):
|
||||||
line_index += 1
|
line_index += 1
|
||||||
indent += " "
|
indent += " "
|
||||||
line_index += 1
|
line_index += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user