Skip to content

Instantly share code, notes, and snippets.

Forked from zaneb/
Created Jun 21, 2019
What would you like to do?
Run flake8 against only files that have changed
set -e
enable_env() {
local env_name="$1"
local env_dir=".tox/${env_name}"
if [ ! -d "${env_dir}" ]; then
if [ ! -f tox.ini ]; then
echo 'No tox.ini found' >&2
exit 1
elif tox -l | grep -q "^${env_name}$$"; then
tox -e"${env_name}" --notest
echo "No ${env_name} tox environment found" >&2
exit 1
source "${env_dir}"/bin/activate
diff_files_branch() {
local branch=${1:-"@{u}"}
git diff --name-only --diff-filter=d "${branch}" -- '*.py'
diff_files() {
diff_files_branch 2>/dev/null || diff_files_branch origin/master
enable_env pep8
flake8 $(diff_files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment