From 1f7e40d04f41569e41a2d606261fceac02a801e9 Mon Sep 17 00:00:00 2001 From: Rak Alexey Date: Mon, 24 Oct 2022 18:24:18 +0300 Subject: [PATCH] Improve check copies (#19829) * print first diff line intead of first code part line * fix style --- utils/check_copies.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/check_copies.py b/utils/check_copies.py index a04c0d13f1..b7ab644982 100644 --- a/utils/check_copies.py +++ b/utils/check_copies.py @@ -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