Skip to content

Commit

Permalink
run black from git pre-commit script
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jan 4, 2024
1 parent a505691 commit 63c3f8b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scripts/internal/git_pre_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ def git_commit_files():
return (py_files, c_files, rst_files, toml_files, new_rm_mv)


def black(files):
print("running black (%s)" % len(files))
cmd = [PYTHON, "-m", "black", "--check", "--safe"] + files
if subprocess.call(cmd) != 0:
return exit(
"Python code didn't pass 'ruff' style check."
"Try running 'make fix-ruff'."
)


def ruff(files):
print("running ruff (%s)" % len(files))
cmd = [PYTHON, "-m", "ruff", "check", "--no-cache"] + files
Expand Down Expand Up @@ -139,6 +149,7 @@ def rstcheck(files):
def main():
py_files, c_files, rst_files, toml_files, new_rm_mv = git_commit_files()
if py_files:
black(py_files)
ruff(py_files)
if c_files:
c_linter(c_files)
Expand Down

0 comments on commit 63c3f8b

Please sign in to comment.