Loading black.py +7 −2 Changes for black.py: 7 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -102,7 +102,9 @@ def main( report = Report() try: if not p.is_file() and str(p) == '-': changed = format_stdin_to_stdout(line_length=line_length, fast=fast) changed = format_stdin_to_stdout( line_length=line_length, fast=fast, write_back=not check ) else: changed = format_file_in_place( p, line_length=line_length, fast=fast, write_back=not check Loading Loading @@ -178,7 +180,9 @@ def format_file_in_place( return True def format_stdin_to_stdout(line_length: int, fast: bool) -> bool: def format_stdin_to_stdout( line_length: int, fast: bool, write_back: bool = False ) -> bool: """Format file on stdin and pipe output to stdout. Return True if changed.""" contents = sys.stdin.read() try: Loading @@ -189,6 +193,7 @@ def format_stdin_to_stdout(line_length: int, fast: bool) -> bool: return False finally: if write_back: sys.stdout.write(contents) Loading tests/test_black.py +1 −1 Changes for tests/test_black.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ def test_piping(self) -> None: try: sys.stdin, sys.stdout = StringIO(source), StringIO() sys.stdin.name = '<stdin>' black.format_stdin_to_stdout(line_length=ll, fast=True) black.format_stdin_to_stdout(line_length=ll, fast=True, write_back=True) sys.stdout.seek(0) actual = sys.stdout.read() finally: Loading Loading
black.py +7 −2 Changes for black.py: 7 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -102,7 +102,9 @@ def main( report = Report() try: if not p.is_file() and str(p) == '-': changed = format_stdin_to_stdout(line_length=line_length, fast=fast) changed = format_stdin_to_stdout( line_length=line_length, fast=fast, write_back=not check ) else: changed = format_file_in_place( p, line_length=line_length, fast=fast, write_back=not check Loading Loading @@ -178,7 +180,9 @@ def format_file_in_place( return True def format_stdin_to_stdout(line_length: int, fast: bool) -> bool: def format_stdin_to_stdout( line_length: int, fast: bool, write_back: bool = False ) -> bool: """Format file on stdin and pipe output to stdout. Return True if changed.""" contents = sys.stdin.read() try: Loading @@ -189,6 +193,7 @@ def format_stdin_to_stdout(line_length: int, fast: bool) -> bool: return False finally: if write_back: sys.stdout.write(contents) Loading
tests/test_black.py +1 −1 Changes for tests/test_black.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ def test_piping(self) -> None: try: sys.stdin, sys.stdout = StringIO(source), StringIO() sys.stdin.name = '<stdin>' black.format_stdin_to_stdout(line_length=ll, fast=True) black.format_stdin_to_stdout(line_length=ll, fast=True, write_back=True) sys.stdout.seek(0) actual = sys.stdout.read() finally: Loading