Repository: psf/black
File: src/black/__init__.py (Python)

Code before:
    root = find_project_root(src)
    sources: Set[Path] = set()
    path_empty(src, "No Path provided. Nothing to do 😴", quiet, verbose, ctx)
    gitignore = get_gitignore(root)

    for s in src:
        if s == "-" and stdin_filename:
            p = Path(stdin_filename)
            is_stdin = True
        else:
            p = Path(s)
            is_stdin = False

        if p.is_dir():
            sources.update(
                gen_python_files(
                    p.iterdir(),
                    root,
                    include_regex,
                    exclude_regex,
                    force_exclude_regex,
                    report,
                    gitignore,
                )
            )
        elif p.is_file():
            normalized_path = normalize_path_maybe_ignore(p, root, report)
            if normalized_path is None:
                continue

            normalized_path = "/" + normalized_path
            # Hard-exclude any files that matches the `--force-exclude` regex.
            if force_exclude_regex:
                force_exclude_match = force_exclude_regex.search(normalized_path)
            else:
                force_exclude_match = None
            if force_exclude_match and force_exclude_match.group(0):
                report.path_ignored(p, "matches the --force-exclude regular expression")
                continue

            if is_stdin:
                p = Path("__BLACK_STDIN_FILENAME__" / p)

            sources.add(p)
        elif s == "-":
            sources.add(p)
        else:
            err(f"invalid path: {s}")
    return sources



Review comment (suggestion):
BTW `--exclude` isn't checked here as it is only checked against recursively found files and directories so the help for your new option is a bit misleading. Only `--force-exclude` is checked.

```console
(black) ichard26@acer-ubuntu:~/programming/oss/black$ echo "print('hello world')" | black -v --force-exclude="hello.*" --stdin-filename="hello.py" -
hello.py ignored: matches the --force-exclude regular expression
No Python files are present to be formatted. Nothing to do 😴
(black) ichard26@acer-ubuntu:~/programming/oss/black$ echo "print('hello world')" | black -v --exclude="hello.*" --stdin-filename="hello.py" -
print("hello world")
reformatted __BLACK_STDIN_FILENAME__/hello.py
All done! ✨ 🍰 ✨
1 file reformatted.
```
**NOTE**: the suggestion above must be applied for this demo to work

Code after:

    root = find_project_root(src)
    sources: Set[Path] = set()
    path_empty(src, "No Path provided. Nothing to do 😴", quiet, verbose, ctx)
    gitignore = get_gitignore(root)

    for s in src:
        if s == "-" and stdin_filename:
            p = Path(stdin_filename)
            is_stdin = True
        else:
            p = Path(s)
            is_stdin = False

        if is_stdin or p.is_file():
            normalized_path = normalize_path_maybe_ignore(p, root, report)
            if normalized_path is None:
                continue

            normalized_path = "/" + normalized_path
            # Hard-exclude any files that matches the `--force-exclude` regex.
            if force_exclude_regex:
                force_exclude_match = force_exclude_regex.search(normalized_path)
            else:
                force_exclude_match = None
            if force_exclude_match and force_exclude_match.group(0):
                report.path_ignored(p, "matches the --force-exclude regular expression")
                continue

            if is_stdin:
                p = Path(f"{STDIN_PLACEHOLDER}{str(p)}")

            sources.add(p)
        elif p.is_dir():
            sources.update(
                gen_python_files(
                    p.iterdir(),
                    root,
                    include_regex,
                    exclude_regex,
                    force_exclude_regex,
                    report,
                    gitignore,
                )
            )
        elif s == "-":
            sources.add(p)
        else:
            err(f"invalid path: {s}")
    return sources