Created
October 28, 2020 23:05
-
-
Save ashwinshankar77/7d5e5ef2f23e612fce349525989abbae to your computer and use it in GitHub Desktop.
Python 3 incompatibility detection using futurize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Add migrated fixers to this file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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