Skip to content

Commit

Permalink
inline normalize_path_maybe_ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Nov 1, 2023
1 parent 0fb2c6e commit f9c4a4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,7 @@ def get_sources(

sources.add(path)
elif path.is_dir():
p_relative = normalize_path_maybe_ignore(path, root, report)
assert p_relative is not None
path = root / p_relative
path = root / (path.resolve().relative_to(root))
if verbose:
out(f'Found input source directory: "{path}"', fg="blue")

Expand Down
5 changes: 3 additions & 2 deletions tests/test_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def _mocked_calls() -> bool:
return _mocked_calls

with patch("pathlib.Path.iterdir", return_value=target_contents), patch(
"pathlib.Path.cwd", return_value=working_directory
"pathlib.Path.resolve", return_value=target_abspath
), patch("pathlib.Path.is_dir", side_effect=mock_n_calls([True])):
# Note that the root folder (project_root) isn't the folder
# named "root" (aka working_directory)
Expand All @@ -526,7 +526,8 @@ def _mocked_calls() -> bool:
for _, mock_args, _ in report.path_ignored.mock_calls
), "A symbolic link was reported."
report.path_ignored.assert_called_once_with(
Path("root", "child", "b.py"), "matches a .gitignore file content"
Path(working_directory, "child", "b.py"),
"matches a .gitignore file content",
)

def test_report_verbose(self) -> None:
Expand Down

0 comments on commit f9c4a4a

Please sign in to comment.