Improve check copies (#19829)

* print first diff line intead of first code part line

* fix style
This commit is contained in:
Rak Alexey
2022-10-24 18:24:18 +03:00
committed by GitHub
parent 8b2501b4b9
commit 1f7e40d04f

View File

@@ -228,7 +228,12 @@ def is_copy_consistent(filename, overwrite=False):
# Test for a diff and act accordingly.
if observed_code != theoretical_code:
diffs.append([object_name, start_index])
diff_index = start_index + 1
for observed_line, theoretical_line in zip(observed_code.split("\n"), theoretical_code.split("\n")):
if observed_line != theoretical_line:
break
diff_index += 1
diffs.append([object_name, diff_index])
if overwrite:
lines = lines[:start_index] + [theoretical_code] + lines[line_index:]
line_index = start_index + 1