diff options
author | anirudnits <aniruddha97bhatt@gmail.com> | 2020-10-02 00:41:10 +0530 |
---|---|---|
committer | anirudnits <aniruddha97bhatt@gmail.com> | 2020-10-02 00:41:10 +0530 |
commit | 6d32601a998cc55a2b72c90f2b91102202ce864c (patch) | |
tree | 7a03e3a566fedbdd1de934fa2e50b683c23c2510 | |
parent | b6c3c5997c0c1079a18ef2f26376875efa279e69 (diff) | |
download | isort-6d32601a998cc55a2b72c90f2b91102202ce864c.tar.gz |
Made sure that verbose output is only shown for modified files
-rw-r--r-- | isort/api.py | 2 | ||||
-rw-r--r-- | isort/core.py | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/isort/api.py b/isort/api.py index f59bc6d9..6c5876be 100644 --- a/isort/api.py +++ b/isort/api.py @@ -210,7 +210,7 @@ def check_stream( ) printer = create_terminal_printer(color=config.color_output) if not changed: - if config.verbose: + if config.verbose and not config.only_modified: printer.success(f"{file_path or ''} Everything Looks Good!") return True else: diff --git a/isort/core.py b/isort/core.py index 22cba49e..7f4c2c8a 100644 --- a/isort/core.py +++ b/isort/core.py @@ -67,6 +67,7 @@ def process( made_changes: bool = False stripped_line: str = "" end_of_file: bool = False + verbose_output: List[str] = [] if config.float_to_top: new_input = "" @@ -87,6 +88,7 @@ def process( current += line_separator + line_separator.join(add_imports) add_imports = [] parsed = parse.file_contents(current, config=config) + verbose_output += parsed.verbose_output extra_space = "" while current and current[-1] == "\n": extra_space += "\n" @@ -325,8 +327,11 @@ def process( line[len(indent) :] for line in import_section.splitlines(keepends=True) ) + parsed_content = parse.file_contents(import_section, config=config) + verbose_output += parsed_content.verbose_output + sorted_import_section = output.sorted_imports( - parse.file_contents(import_section, config=config), + parsed_content, _indented_config(config, indent), extension, import_type="cimport" if cimports else "import", @@ -384,6 +389,10 @@ def process( output_stream.write(new_line) stripped_line = new_line.strip().split("#")[0] + if made_changes and config.only_modified: + for output_str in verbose_output: + print(output_str) + return made_changes |