Skip to content

Instantly share code, notes, and snippets.

@PeterJCLaw
Created July 23, 2020 18:32
Show Gist options
  • Select an option

  • Save PeterJCLaw/6901e4af1121b0fffc39d89c6d83e4cc to your computer and use it in GitHub Desktop.

Select an option

Save PeterJCLaw/6901e4af1121b0fffc39d89c6d83e4cc to your computer and use it in GitHub Desktop.
Aliases useful for linting changes in a Python project in a git repo
# Python Project things
run-py-branch() { git diff origin/master... --name-only --diff-filter=d | grep '\.py$' | xargs --no-run-if-empty "$@"; }
run-py-local() { git diff --name-only --diff-filter=d | grep '\.py$' | xargs --no-run-if-empty "$@"; }
run-py-cache() { git diff --cached --name-only --diff-filter=d | grep '\.py$' | xargs --no-run-if-empty "$@"; }
isort-branch() { run-py-branch isort; }
isort-local() { run-py-local isort; }
isort-cache() { run-py-cache isort; }
flake8-branch() { run-py-branch flake8; }
flake8-local() { run-py-local flake8; }
flake8-cache() { run-py-cache flake8; }
fix8-only-branch() { run-py-branch /home/play/fix8/fix8.py; }
fix8-only-local() { run-py-local /home/play/fix8/fix8.py; }
fix8-only-cache() { run-py-cache /home/play/fix8/fix8.py; }
fix8-branch() { fix8-only-branch && isort-branch; }
fix8-local() { fix8-only-local && isort-local; }
fix8-cache() { fix8-only-cache && isort-cache; }
mypy-branch() { run-py-branch mypy; }
mypy-local() { run-py-local mypy; }
mypy-cache() { run-py-cache mypy; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment