Improve check copies (#19829)
* print first diff line intead of first code part line * fix style
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user