Add special config verbose log case when black is using user-level config (#2861)
This commit is contained in:
parent
8089aaad6b
commit
c26c7728e8
@ -35,6 +35,8 @@
|
||||
|
||||
<!-- Changes to Black's terminal output and error messages -->
|
||||
|
||||
- In verbose, mode, log when _Black_ is using user-level config (#2861)
|
||||
|
||||
### Packaging
|
||||
|
||||
<!-- Changes to how Black is packaged, such as dependency requirements -->
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user