Skip to content
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

[REF] duplicate-code: Check disabled from first line to top code line #1012

Closed
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
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ Release date: tba

Closes issue #968

* Fix ignored *disable=duplicate-code* on top file


What's new in Pylint 1.6.2?
===========================
Expand Down
2 changes: 2 additions & 0 deletions doc/whatsnew/2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ Bug fixes
* Fix a false positive of 'redundant-returns-doc', occurred when the documented
function was using *yield* instead of *return*.

* Fix ignored *disable=duplicate-code* on top file

Removed Changes
===============

Expand Down
6 changes: 6 additions & 0 deletions pylint/checkers/similar.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ def process_module(self, node):

stream must implement the readlines method
"""
if not self.linter.is_message_enabled('R0801') or not node.body:
return

for top_line in range(1, node.body[0].lineno):
if not self.linter.is_message_enabled('R0801', top_line):
return
with node.stream() as stream:
self.append_stream(self.linter.current_name,
stream,
Expand Down