Skip to content

Instantly share code, notes, and snippets.

@ashwinshankar77
Created October 28, 2020 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashwinshankar77/7d5e5ef2f23e612fce349525989abbae to your computer and use it in GitHub Desktop.
Save ashwinshankar77/7d5e5ef2f23e612fce349525989abbae to your computer and use it in GitHub Desktop.
Python 3 incompatibility detection using futurize
//Add migrated fixers to this file
#!/bin/bash
set -e
# Enter space separated list of files to ignore. Note that this will ignore the files for all fixers.
declare -a EXLUDE_FILES=("dags/foo")
for file in ${EXLUDE_FILES[@]}; do
[ -f $file ] && mv $file $file.ignore
done
TMP="$(mktemp -d "/tmp/futurize-airflow-XXXXXX")"
echo $TMP
trap "rm -rf $TMP" EXIT INT QUIT TERM
# Create a new virtual environement to install futurize
VENV=".future-venv"
virtualenv --python=python3 "$VENV"
source $VENV/bin/activate
pip install future
# Create the futurize command to run
CMD="futurize"
for i in $(cat ./migrated-fixers);do
CMD="$CMD -f $i"
done
CMD="$CMD dags/ lib/ plugins/ tests/"
echo $CMD
eval '$CMD' | tee "$TMP/output"
# If there are incompatibilities, then the output file will not be empty. Exit with error if thats the case.
if [ -s "$TMP/output" ]; then
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment