OILS / devtools / types.sh View on Github | oilshell.org

66 lines, 31 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# devtools/types.sh <function name>
5
6: ${LIB_OSH=stdlib/osh}
7source $LIB_OSH/bash-strict.sh
8source $LIB_OSH/task-five.sh # run-task
9
10source build/dev-shell.sh # python3 in $PATH
11
12readonly MYPY_FLAGS='--strict --no-strict-optional'
13
14# Note: similar to egrep filename filters in build/dynamic-deps.sh
15readonly COMMENT_RE='^[ ]*#'
16
17typecheck-files() {
18 # The --follow-imports=silent option allows adding type annotations
19 # in smaller steps without worrying about triggering a bunch of
20 # errors from imports. In the end, we may want to remove it, since
21 # everything will be annotated anyway. (that would require
22 # re-adding assert-one-error and its associated cruft, though).
23
24 # NOTE: This got a lot slower once we started using the MyPy repo, instead of
25 # the optimized package from pip
26 # Consider installing the package again
27 echo "MYPY $@"
28 time MYPYPATH='.:pyext' python3 -m mypy --py2 --follow-imports=silent $MYPY_FLAGS "$@"
29 echo
30}
31
32check-oils() {
33 # TODO: remove --no-warn-unused-ignores and type: ignore in
34 # osh/builtin_comp.py after help_.py import isn't conditional
35
36 cat _build/NINJA/bin.oils_for_unix/typecheck.txt \
37 | xargs -- $0 typecheck-files --no-warn-unused-ignores
38}
39
40# NOTE: Becoming obsolete as typecheck filters in build/dynamic-deps.sh are whittled down
41check-more() {
42 egrep -v "$COMMENT_RE" devtools/typecheck-more.txt \
43 | xargs -- $0 typecheck-files
44}
45
46check-all() {
47 ### Run this locally
48
49 check-oils
50
51 # Ad hoc list of additional files
52 check-more
53}
54
55soil-run() {
56 set -x
57 python3 -m mypy --version
58 set +x
59
60 # Generate oils-for-unix dependencies. Though this is overly aggressive
61 ./NINJA-config.sh
62
63 check-all
64}
65
66task-five "$@"