Skip to content

Commit

Permalink
fix invoke ruff always exiting with zero status (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsnider2195 authored Sep 13, 2024
1 parent 26d2d99 commit 8f21e73
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def run_command(context, command, **kwargs):
**kwargs.get("env", {}),
**kwargs.pop("command_env"),
}
context.run(command, **kwargs)
return context.run(command, **kwargs)
else:
# Check if nautobot is running, no need to start another nautobot container to run a command
docker_compose_status = "ps --services --filter status=running"
Expand All @@ -175,7 +175,7 @@ def run_command(context, command, **kwargs):

pty = kwargs.pop("pty", True)

docker_compose(context, compose_command, pty=pty, **kwargs)
return docker_compose(context, compose_command, pty=pty, **kwargs)


# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -724,20 +724,26 @@ def ruff(context, action=None, target=None, fix=False, output_format="concise"):
if not target:
target = ["."]

exit_code = 0

if "format" in action:
command = "ruff format "
if not fix:
command += "--check "
command += " ".join(target)
run_command(context, command, warn=True)
if not run_command(context, command, warn=True):
exit_code = 1

if "lint" in action:
command = "ruff check "
if fix:
command += "--fix "
command += f"--output-format {output_format} "
command += " ".join(target)
run_command(context, command, warn=True)
if not run_command(context, command, warn=True):
exit_code = 1

raise Exit(code=exit_code)


@task
Expand Down

0 comments on commit 8f21e73

Please sign in to comment.