Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add invoke check cmd
update pipenv scripts and make commands
  • Loading branch information
Kilo59 committed Mar 29, 2020
commit cabb9dfe317ee11c4e3b9f1ecd53e4e4c172faf7
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ lint:
pylint $(APP) || true

fmt:
isort --apply --atomic
black . -l 120
invoke fmt

check-fmt:
isort -rc --check
black . --check --diff
invoke check --fmt --sort
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ python_version = "3.8"
[scripts]
dev = "uvicorn app.main:APP --reload"
start = "uvicorn app.main:APP"
fmt = "black . -l 120"
sort = "isort --apply --atomic"
fmt = "invoke fmt"
sort = "invoke sort"
19 changes: 19 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,22 @@ def fmt(ctx, targets="."):
print("formatting ...")
args = ["black", targets]
ctx.run(" ".join(args))

@invoke.task
def check(ctx, fmt=False, sort=False):
"""Check code format and import order."""
if not any([fmt, sort]):
fmt = True
sort = True

fmt_args = ["black", "--check", "--diff", "."]
sort_args = ["isort", "-rc", "--check", "--diff", "."]
cmd_args = []

if fmt:
cmd_args.extend(fmt_args)
if sort:
if cmd_args:
cmd_args.append("&")
cmd_args.extend(sort_args)
ctx.run(" ".join(cmd_args))