Skip to content

Commit

Permalink
allows stdin formatting for files outside the current tree
Browse files Browse the repository at this point in the history
fixes psf#3207
  • Loading branch information
n-borges committed Aug 4, 2022
1 parent 507234c commit 79a1d91
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/black/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ def normalize_path_maybe_ignore(
abspath = path if path.is_absolute() else Path.cwd() / path
normalized_path = abspath.resolve()
try:
root_relative_path = normalized_path.relative_to(root).as_posix()
if not str(normalized_path).startswith(str(root)):
root_relative_path = os.path.join(Path.cwd(), path)
else:
root_relative_path = normalized_path.relative_to(root).as_posix()
except ValueError:
if report:
report.path_ignored(
Expand Down

0 comments on commit 79a1d91

Please sign in to comment.