Skip to content

Commit

Permalink
Fix integration between stdin filename and --force-exclude (#4539)
Browse files Browse the repository at this point in the history
  • Loading branch information
MeGaGiGaGon authored Dec 28, 2024
1 parent 3b00112 commit 9431e98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@

<!-- For example, Docker, GitHub Actions, pre-commit, editors -->

- If using stdin with `--stdin-filename` set to a force excluded path, stdin won't be
formatted. (#4539)

### Documentation

<!-- Major changes to documentation and policies. Small docs changes
Expand Down
6 changes: 6 additions & 0 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,12 @@ def get_sources(
for s in src:
if s == "-" and stdin_filename:
path = Path(stdin_filename)
if path_is_excluded(stdin_filename, force_exclude):
report.path_ignored(
path,
"--stdin-filename matches the --force-exclude regular expression",
)
continue
is_stdin = True
else:
path = Path(s)
Expand Down

0 comments on commit 9431e98

Please sign in to comment.