| 1 | #!/usr/bin/env bash
|
| 2 | #
|
| 3 | # Usage:
|
| 4 | # types/run.sh <function name>
|
| 5 |
|
| 6 | set -o nounset
|
| 7 | set -o pipefail
|
| 8 | set -o errexit
|
| 9 |
|
| 10 | source devtools/common.sh
|
| 11 |
|
| 12 | readonly PY_PATH='.:vendor/' # note: could consolidate with other scripts
|
| 13 |
|
| 14 | #
|
| 15 | # PyAnnotate
|
| 16 | #
|
| 17 |
|
| 18 | # 2025-01: These old versions could go in vendor/ ! They're still useful.
|
| 19 |
|
| 20 | # September 2019
|
| 21 | PYANN_URL='https://files.pythonhosted.org/packages/0d/26/2f68c02fae0b88d9cefdbc632edad190d61621b5660c72c920be1e52631e/pyannotate-1.2.0.tar.gz'
|
| 22 |
|
| 23 | # October 2019
|
| 24 | MYPY_EXT_URL='https://files.pythonhosted.org/packages/63/60/0582ce2eaced55f65a4406fc97beba256de4b7a95a0034c6576458c6519f/mypy_extensions-0.4.3.tar.gz'
|
| 25 |
|
| 26 | # December 2024
|
| 27 | SIX_URL='https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz'
|
| 28 |
|
| 29 | download-tarballs() {
|
| 30 | wget --no-clobber --directory _tmp \
|
| 31 | $PYANN_URL $MYPY_EXT_URL $SIX_URL
|
| 32 | }
|
| 33 |
|
| 34 | extract-tarballs() {
|
| 35 | pushd _tmp
|
| 36 | for t in pyannotate-*.gz mypy_extensions-*.gz six-*.gz; do
|
| 37 | echo "=== $t"
|
| 38 | tar -x -z < $t
|
| 39 | done
|
| 40 | popd
|
| 41 | }
|
| 42 |
|
| 43 | PY_PATH_2='.:vendor:_tmp/pyannotate-1.2.0:_tmp/mypy_extensions-0.4.3:_tmp/six-1.17.0'
|
| 44 |
|
| 45 | collect-types() {
|
| 46 | # syntax error?
|
| 47 | # Now it requires python3
|
| 48 | # I think we need an old release
|
| 49 | # https://pypi.org/project/mypy-extensions/
|
| 50 | # https://github.com/python/mypy_extensions
|
| 51 | # TypedDict
|
| 52 | # https://github.com/python/mypy_extensions/commit/e0c6670e05a87507d59b7d3a0aa2eec88e9813b0
|
| 53 |
|
| 54 | #local ext=~/git/oils-for-unix/mypy_extensions
|
| 55 | #export PYTHONPATH=".:$PYANN_REPO:$ext"
|
| 56 |
|
| 57 | PYTHONPATH=$PY_PATH_2 devtools/pyann_driver.py "$@"
|
| 58 |
|
| 59 | ls -l type_info.json
|
| 60 | wc -l type_info.json
|
| 61 | }
|
| 62 |
|
| 63 | peek-type-info() {
|
| 64 | grep path type_info.json | sort | uniq -c | sort -n
|
| 65 | }
|
| 66 |
|
| 67 | apply-types() {
|
| 68 | local json=${1:-type_info.json}
|
| 69 | shift
|
| 70 | #local -a files=(osh/builtin_comp.py core/completion.py)
|
| 71 | local -a files=(doctools/*.py)
|
| 72 |
|
| 73 | #local -a files=( $(cat _tmp/osh-parse-src.txt | grep -v syntax_asdl.py ) )
|
| 74 |
|
| 75 | # Use -w to write files
|
| 76 | set -x
|
| 77 | PYTHONPATH=$PY_PATH_2 \
|
| 78 | python2 -m pyannotate_tools.annotations --type-info $json "${files[@]}" "$@"
|
| 79 |
|
| 80 | #pyann-patched --type-info $json "${files[@]}" "$@"
|
| 81 | }
|
| 82 |
|
| 83 | "$@"
|