GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • All gists
  • Back to GitHub
  • Sign in
  • Sign up
  • Code
  • Revisions 2
  • Stars 3
  • Terms
  • Privacy
  • Security
  • Status
  • Community
  • Docs
  • Contact

This view

  • Original page
  • New address

GeezerVison is showing gist.github.com — Python pre-commit hook with isort and black

Instantly share code, notes, and snippets.

@IdleSys

IdleSys/pre-commit

Last active January 1, 2026 00:38
Show Gist options
  • Download ZIP
  • Star 3 (3) You must be signed in to star a gist
  • Fork 0 (0) You must be signed in to fork a gist
  • Clone this repository at <script src="https://gist.github.com/IdleSys/a78ddcd494759a6d462375370cc3f84e.js"></script>
  • Save IdleSys/a78ddcd494759a6d462375370cc3f84e to your computer and use it in GitHub Desktop.
Clone this repository at <script src="https://gist.github.com/IdleSys/a78ddcd494759a6d462375370cc3f84e.js"></script>
Save IdleSys/a78ddcd494759a6d462375370cc3f84e to your computer and use it in GitHub Desktop.
Download ZIP
Python pre-commit hook with isort and black
Raw
pre-commit
#!/bin/bash
if ! command -v isort &> /dev/null
then
echo "isort is not installed, installing it..."
pip install isort
else
echo "isort is already installed"
fi
if ! command -v black &> /dev/null
then
echo "black is not installed, installing it..."
pip install black
else
echo "black is already installed"
fi
echo "Running isort and black on all Python files..."
changed_files=$(git diff --name-only --cached --diff-filter=d -- "*.py")
if ! [ -z "$name" ]; then
isort $changed_files
black $changed_files
git add $changed_files
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.