X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/a5fde8ab9be26221d01bdd0a426db07cdb6f0f04..c47b91f513052cd39b818ea7c19716423c85c04e:/src/black/files.py?ds=inline diff --git a/src/black/files.py b/src/black/files.py index 17515d5..d51c1bc 100644 --- a/src/black/files.py +++ b/src/black/files.py @@ -39,7 +39,9 @@ if TYPE_CHECKING: @lru_cache() -def find_project_root(srcs: Sequence[str]) -> Tuple[Path, str]: +def find_project_root( + srcs: Sequence[str], stdin_filename: Optional[str] = None +) -> Tuple[Path, str]: """Return a directory containing .git, .hg, or pyproject.toml. That directory will be a common parent of all files and directories @@ -52,6 +54,8 @@ def find_project_root(srcs: Sequence[str]) -> Tuple[Path, str]: the second element as a string describing the method by which the project root was discovered. """ + if stdin_filename is not None: + srcs = tuple(stdin_filename if s == "-" else s for s in srcs) if not srcs: srcs = [str(Path.cwd().resolve())]