diff options
-rw-r--r-- | checkers/similar.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/checkers/similar.py b/checkers/similar.py index 593d541..9542077 100644 --- a/checkers/similar.py +++ b/checkers/similar.py @@ -299,7 +299,10 @@ class SimilarChecker(BaseChecker, Similar): stream must implement the readlines method """ - self.append_stream(self.linter.current_name, node.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)""" @@ -360,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) |