Repository: psf/black

Issue:
Output claims the configuration came from project root (filesystem root) when in reality it was user-level config.
**Describe the bug**

The verbose would claim that the filesystem root was identified as the project root (this is correct) and the configuration file came from `/pyproject.toml` (this is false). 

**To Reproduce**

- Create a test file in a directory where is no pyproject.toml present (up the filesystem root)
- Format it with Black with `--verbose`
- Create a [user level config file](https://black.readthedocs.io/en/latest/usage_and_configuration/the_basics.html#where-black-looks-for-the-file) and configure line length to be something very small
- Reformat using the same command and observe the wrong output

```console
❯ black test.py --check -v
Identified `/` as project root containing a file system root.
Sources to be formatted: "home/ichard26/programming/oss/test.py"
test.py already well formatted, good job.

All done! ✨ 🍰 ✨
1 file would be left unchanged.

❯ echo "[tool.black]
  line-length = 10" > ~/.config/black

❯ black test.py --check -v
Identified `/` as project root containing a file system root.
Sources to be formatted: "home/ichard26/programming/oss/test.py"
Using configuration from project root.
would reformat test.py

Oh no! 💥 💔 💥
1 file would be reformatted.
```

**Expected behavior**

That the output would report either it came from user level configuration or at least not claim it was project configuration 'cause it's not.

**Environment**

- Black's version: 22.1.0 and d038a24ca200da9dacc1dcb05090c9e5b45b7869
- OS and Python version: CPython 3.8.5 under Ubuntu 20.04.03 LTS

**Additional context**

This made it _very_ confusing to debug an unrelated test suite issue :)

cc @Shivansh-007 


Discussion:
I would look into this 👍🏻 

Resolving patch:
diff --git a/src/black/__init__.py b/src/black/__init__.py
--- a/src/black/__init__.py
+++ b/src/black/__init__.py
@@ -49,7 +49,12 @@
 from black.concurrency import cancel, shutdown, maybe_install_uvloop
 from black.output import dump_to_file, ipynb_diff, diff, color_diff, out, err
 from black.report import Report, Changed, NothingChanged
-from black.files import find_project_root, find_pyproject_toml, parse_pyproject_toml
+from black.files import (
+    find_project_root,
+    find_pyproject_toml,
+    parse_pyproject_toml,
+    find_user_pyproject_toml,
+)
 from black.files import gen_python_files, get_gitignore, normalize_path_maybe_ignore
 from black.files import wrap_stream_for_windows
 from black.parsing import InvalidInput  # noqa F401
@@ -402,7 +407,7 @@ def validate_regex(
     help="Read configuration from FILE path.",
 )
 @click.pass_context
-def main(
+def main(  # noqa: C901
     ctx: click.Context,
     code: Optional[str],
     line_length: int,
@@ -469,7 +474,17 @@ def main(
 
         if config:
             config_source = ctx.get_parameter_source("config")
-            if config_source in (ParameterSource.DEFAULT, ParameterSource.DEFAULT_MAP):
+            user_level_config = str(find_user_pyproject_toml())
+            if config == user_level_config:
+                out(
+                    f"Using configuration from user-level config at "
+                    f"'{user_level_config}'.",
+                    fg="blue",
+                )
+            elif config_source in (
+                ParameterSource.DEFAULT,
+                ParameterSource.DEFAULT_MAP,
+            ):
                 out("Using configuration from project root.", fg="blue")
             else:
                 out(f"Using configuration in '{config}'.", fg="blue")


Test patch: