<commit_before>#!/bin/bash

# TODO: until 3.6 safe, force 3.5
PYV="3.5"
FAUCETHOME=`dirname $0`"/../.."
PYTHONPATH=$FAUCETHOME:$FAUCETHOME/faucet:$FAUCETHOME/clib
SRCFILES="$FAUCETHOME/tests/codecheck/src_files.sh"

TMPD=`mktemp -d`
test -d $TMPD || exit
function cleanup {
  rm -r "$TMPD"
}
trap cleanup EXIT

PYTYPEARGS="pytype -V$PYV -o $TMPD --pythonpath $PYTHONPATH -d pyi-error,import-error -v2"

declare -A SRCDIRS
for f in `$SRCFILES` ; do
   d=`dirname $f`
   SRCDIRS[$d]="$f ${SRCDIRS[$d]}"
done

for d in "${!SRCDIRS[@]}" ; do
   srcfiles=${SRCDIRS[$d]}
   $PYTYPEARGS $srcfiles || exit 1
done
<commit_msg>Still need to use parallel for pytype as pytype uses lots of memory.<commit_after>#!/bin/bash

# TODO: pytype is very memory intensive - run per separate directory to limit resources.
# TODO: until 3.6 safe, force 3.5
PYV="3.5"
FAUCETHOME=`dirname $0`"/../.."
PYTHONPATH=$FAUCETHOME:$FAUCETHOME/faucet:$FAUCETHOME/clib
SRCFILES="$FAUCETHOME/tests/codecheck/src_files.sh"

TMPD=`mktemp -d`
test -d $TMPD || exit
function cleanup {
  rm -r "$TMPD"
}
trap cleanup EXIT

PYTYPEARGS="pytype -V$PYV -o $TMPD --pythonpath $PYTHONPATH -d pyi-error,import-error"

declare -A SRCDIRS
for f in `$SRCFILES` ; do
   d=`dirname $f`
   if [ "SRCDIRS[$d]]" ] ; then
       SRCDIRS[$d]="$f\n${SRCDIRS[$d]}"
   else
       SRCDIRS[$d]=$f
   fi
done

PARARGS="parallel --delay 1 --bar"
for d in "${!SRCDIRS[@]}" ; do
   srcfiles=${SRCDIRS[$d]}
   echo -e $d: $srcfiles
   echo -e $srcfiles | $PARARGS $PYTYPEARGS || exit 1
done

{'fraction_non_alphanumeric': 0.17365661861074705, 'fraction_numerical': 0.011795543905635648, 'mean_word_length': 3.973941368078176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6581121', 'n_tokens_mistral': 661, 'n_tokens_neox': 636, 'n_words': 158}