Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@

<!-- Changes to Black's terminal output and error messages -->

- Write unchanged content to stdout when excluding formating from stdin using pipes
(#4610)

### _Blackd_

<!-- Changes to blackd -->
Expand Down
26 changes: 6 additions & 20 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
Iterator,
MutableMapping,
Sequence,
Sized,
)
from contextlib import contextmanager
from dataclasses import replace
Expand Down Expand Up @@ -681,13 +680,12 @@ def main( # noqa: C901
except GitWildMatchPatternError:
ctx.exit(1)

path_empty(
sources,
"No Python files are present to be formatted. Nothing to do 😴",
quiet,
verbose,
ctx,
)
if not sources:
if verbose or not quiet:
out("No Python files are present to be formatted. Nothing to do 😴")
if "-" in src:
sys.stdout.write(sys.stdin.read())
ctx.exit(0)

if len(sources) == 1:
reformat_one(
Expand Down Expand Up @@ -820,18 +818,6 @@ def get_sources(
return sources


def path_empty(
src: Sized, msg: str, quiet: bool, verbose: bool, ctx: click.Context
) -> None:
"""
Exit if there is no `src` provided for formatting
"""
if not src:
if verbose or not quiet:
out(msg)
ctx.exit(0)


def reformat_code(
content: str,
fast: bool,
Expand Down