Skip to content

Commit

Permalink
Format code style
Browse files Browse the repository at this point in the history
  • Loading branch information
yukihiko-shinoda committed May 25, 2020
1 parent d3852dc commit 05694a9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions {{cookiecutter.project_slug}}/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,21 @@ def style(context, check=False):
"""
Format code
"""
for result in [isort(context, check), pipenv_setup(context, check), black(context, check)]:
for result in [
isort(context, check),
pipenv_setup(context, check),
black(context, check),
]:
if result.failed:
raise Failure(result)


def isort(context, check=False) -> Result:
"""Runs isort."""
isort_options = "--recursive {}".format("--check-only --diff" if check else "")
return context.run("isort {} {}".format(isort_options, " ".join(PYTHON_DIRS)), warn=True)
return context.run(
"isort {} {}".format(isort_options, " ".join(PYTHON_DIRS)), warn=True
)


def pipenv_setup(context, check=False) -> Result:
Expand All @@ -64,7 +70,9 @@ def pipenv_setup(context, check=False) -> Result:
def black(context, check=False) -> Result:
"""Runs black."""
black_options = "{}".format("--check --diff" if check else "")
return context.run("black {} {}".format(black_options, " ".join(PYTHON_DIRS)), warn=True)
return context.run(
"black {} {}".format(black_options, " ".join(PYTHON_DIRS)), warn=True
)


@task
Expand Down

0 comments on commit 05694a9

Please sign in to comment.