Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python 3 incompatibility detection using futurize
//Add migrated fixers to this file
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
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
virtualenv --python=python3 "$VENV"
source $VENV/bin/activate
pip install future
# Create the futurize command to run
for i in $(cat ./migrated-fixers);do
CMD="$CMD -f $i"
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment