Skip to content

empty-comment line number bug fix #4010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
------------------
Pylint's ChangeLog
------------------
* Bug fix for empty-comment message line number.

Closes #4009

* Only emit `bad-reversed-sequence` on dictionaries if below py3.8

Closes #3940
Expand Down
2 changes: 1 addition & 1 deletion pylint/extensions/empty_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def process_module(self, node):
line = line.rstrip()
if line.endswith(b"#"):
if not is_line_commented(line[:-1]):
self.add_message("empty-comment", line=line_num)
self.add_message("empty-comment", line=line_num + 1)


def register(linter):
Expand Down
8 changes: 4 additions & 4 deletions tests/extensions/test_empty_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_comment_base_case(linter):
for msg in msgs:
assert msg.symbol == "empty-comment"
assert msg.msg == "Line with empty comment"
assert msgs[0].line == 1
assert msgs[1].line == 2
assert msgs[2].line == 4
assert msgs[3].line == 6
assert msgs[0].line == 2
assert msgs[1].line == 3
assert msgs[2].line == 5
assert msgs[3].line == 7