Skip to content

Commit d1048a1

Browse files
[duplicate-code] Remove trailing whitespaces in similarity report
And fix tests/checkers/unittest_similar.py that required to have some
1 parent c983d7d commit d1048a1

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Release date: TBA
2222

2323
Closes #4648
2424

25+
* The ``similarity`` checker no longer add three trailing whitespaces for
26+
empty lines in its report.
27+
2528

2629
What's New in Pylint 2.9.2?
2730
===========================

pylint/checkers/similar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def _get_similarity_report(self, similarities: List[Tuple]) -> str:
127127
report += f"=={line_set.name}:{idx}\n"
128128
if line_set:
129129
for line in line_set._real_lines[idx : idx + number]:
130-
report += f" {line.rstrip()}\n"
130+
report += f" {line.rstrip()}\n" if line.rstrip() else "\n"
131131
duplicated_line_number += number * (len(files) - 1)
132132
total_line_number: int = sum(len(lineset) for lineset in self.linesets)
133133
report += "TOTAL lines={} duplicates={} percent={:.2f}\n".format(

tests/checkers/unittest_similar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def test_ignore_signatures_fail():
175175
arg5: int = 5
176176
) -> Ret1:
177177
pass
178-
178+
179179
def example():
180180
"""Valid function definition with docstring only."""
181181
TOTAL lines=29 duplicates=10 percent=34.48

0 commit comments

Comments
 (0)