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