Skip to content

Commit

Permalink
Add: Support for reporting formatting progress
Browse files Browse the repository at this point in the history
Add support for reporting the formatting progress via the new autohooks
API.
  • Loading branch information
bjoernricks committed Aug 2, 2022
1 parent 8636e18 commit df5a3a3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion autohooks/plugins/isort/isort.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_isort_arguments(config: Config):


def precommit(
config: Config = None, **kwargs
config: Config = None, report_progress=None, **kwargs
): # pylint: disable=unused-argument
check_isort_installed()

Expand All @@ -80,6 +80,9 @@ def precommit(
ok("No staged files for isort available")
return 0

if report_progress:
report_progress.init(len(files))

arguments = ["isort"]
arguments.extend(get_isort_arguments(config))

Expand All @@ -91,6 +94,8 @@ def precommit(

subprocess.check_call(args)
ok(f"Running isort on {str(f.path)}")
if report_progress:
report_progress.update()
except subprocess.CalledProcessError as e:
error(f"Running isort on {str(f.path)}")
raise e from None
Expand Down

0 comments on commit df5a3a3

Please sign in to comment.