Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: third_party/pylint/checkers/similar.py

Issue 876793002: pylint: upgrade to 1.4.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pylint/checkers/python3.py ('k') | third_party/pylint/checkers/spelling.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pylint/checkers/similar.py
diff --git a/third_party/pylint/checkers/similar.py b/third_party/pylint/checkers/similar.py
index 013f1b0f698b4cc0e4e1a3c8e7b8be7bfaa6290f..95420776110df0cf0fc5d3db79469e9b89bf6476 100644
--- a/third_party/pylint/checkers/similar.py
+++ b/third_party/pylint/checkers/similar.py
@@ -42,7 +42,6 @@ class Similar(object):
def append_stream(self, streamid, stream, encoding=None):
"""append a file to search for similarities"""
- stream.seek(0) # XXX may be removed with astroid > 0.23
if encoding is None:
readlines = stream.readlines
else:
@@ -300,7 +299,10 @@ class SimilarChecker(BaseChecker, Similar):
stream must implement the readlines method
"""
- self.append_stream(self.linter.current_name, node.file_stream, node.file_encoding)
+ with node.stream() as stream:
+ self.append_stream(self.linter.current_name,
+ stream,
+ node.file_encoding)
def close(self):
"""compute and display similarities on closing (i.e. end of parsing)"""
@@ -361,7 +363,8 @@ def Run(argv=None):
usage(1)
sim = Similar(min_lines, ignore_comments, ignore_docstrings, ignore_imports)
for filename in args:
- sim.append_stream(filename, open(filename))
+ with open(filename) as stream:
+ sim.append_stream(filename, stream)
sim.run()
sys.exit(0)
« no previous file with comments | « third_party/pylint/checkers/python3.py ('k') | third_party/pylint/checkers/spelling.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698