mirror of
https://github.com/google/bumble.git
synced 2026-06-16 09:52:27 +00:00
use isort when formatting
This commit is contained in:
@@ -16,16 +16,17 @@
|
||||
Invoke tasks
|
||||
"""
|
||||
|
||||
import glob
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Imports
|
||||
# -----------------------------------------------------------------------------
|
||||
import os
|
||||
import glob
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from invoke import task, call, Collection
|
||||
from invoke.exceptions import Exit, UnexpectedExit
|
||||
|
||||
from invoke import Collection, call, task
|
||||
from invoke.exceptions import Exit, UnexpectedExit
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
@@ -136,12 +137,20 @@ def lint(ctx, disable='C,R', errors_only=False):
|
||||
# -----------------------------------------------------------------------------
|
||||
@task
|
||||
def format_code(ctx, check=False, diff=False):
|
||||
|
||||
options = []
|
||||
if check:
|
||||
options.append("--check")
|
||||
if diff:
|
||||
options.append("--diff")
|
||||
|
||||
print(">>> Sorting imports...")
|
||||
try:
|
||||
ctx.run(f"isort {' '.join(options)} .")
|
||||
except UnexpectedExit as exc:
|
||||
print("Please run 'invoke project.format' or 'isort .' to format the code. ❌")
|
||||
raise Exit(code=1) from exc
|
||||
|
||||
print(">>> Running the formatter...")
|
||||
try:
|
||||
ctx.run(f"black -S {' '.join(options)} .")
|
||||
|
||||
Reference in New Issue
Block a user