Respect a formatter's newline setting when printing

In working on flake8-json, I noticed that setting newline was only
helpful for writing to an ouput-file but not to standard-out. It makes
sense for this setting to apply to both branches otherwise plugins need
to override the method to get the behaviour they expect.
This commit is contained in:
Ian Stapleton Cordasco 2017-12-31 18:50:59 -06:00
parent 3530870679
commit 49f0fbcf1e
No known key found for this signature in database
GPG key ID: C9D7A2604B4FCB2A
2 changed files with 5 additions and 5 deletions

View file

@ -172,7 +172,7 @@ class BaseFormatter(object):
if self.output_fd is not None:
self.output_fd.write(output + self.newline)
if self.output_fd is None or self.options.tee:
print(output)
print(output, end=self.newline)
def write(self, line, source):
"""Write the line either to the output file or stdout.