mypy: Switch default to daemon mode.

There isn't any real advantage to running the non-daemon mode at this
point.
This commit is contained in:
Tim Abbott 2018-12-16 20:49:33 -08:00
parent 7485cb2a50
commit f3c6d91e69
3 changed files with 15 additions and 17 deletions

View File

@ -114,19 +114,15 @@ To run mypy on Zulip's python code, you can run the command:
tools/run-mypy tools/run-mypy
You can also run mypy as a long-running daemon (server) process and send This will take a while to start running, since it runs mypy as a
type-checking requests to the server via the command: long-running daemon (server) process and send type-checking requests
to the server; this makes checking mypy about 100x faster. But if
you're debugging or for whatever reason don't want the daemon, you can
use:
tools/run-mypy -d tools/run-mypy --no-daemon
While the mypy daemon is experimental and currently supports macOS and Linux Mypy outputs errors in the same style as a compiler would. For
only, **we strongly recommend using the daemon** if it is an option. Program
state from previous runs will be cached in memory and will not have to be
read from the file system on each run. For a large codebase like Zulip's
and a workflow involving running mypy repeatedly after small edits, using
the daemon can be *10 or more times faster*.
Mypy will output errors in the same style as a compiler would. For
example, if your code has a type error like this: example, if your code has a type error like this:
``` ```

View File

@ -13,7 +13,9 @@ set -x
# We run mypy after the backend tests so we get output from the # We run mypy after the backend tests so we get output from the
# backend tests, which tend to uncover more serious problems, first. # backend tests, which tend to uncover more serious problems, first.
./tools/run-mypy --version ./tools/run-mypy --version
./tools/run-mypy # We run mypy without daemon mode, since that's faster given that
# we're only going to run it once.
./tools/run-mypy --no-daemon
./tools/test-migrations ./tools/test-migrations
./tools/setup/optimize-svg ./tools/setup/optimize-svg

View File

@ -28,7 +28,7 @@ parser.add_argument('--quick', action='store_true',
help="pass --quick to mypy") help="pass --quick to mypy")
parser.add_argument('-m', '--modified', action='store_true', parser.add_argument('-m', '--modified', action='store_true',
help="check only modified files") help="check only modified files")
parser.add_argument('-d', '--daemon', action='store_true', parser.add_argument('--no-daemon', action='store_true',
help="Start and run the mypy fine-grained incremental daemon") help="Start and run the mypy fine-grained incremental daemon")
parser.add_argument('--scripts-only', action='store_true', parser.add_argument('--scripts-only', action='store_true',
help="only check extensionless python scripts") help="only check extensionless python scripts")
@ -45,7 +45,7 @@ if not args.force:
print('If you really know what you are doing, use --force to run anyway.') print('If you really know what you are doing, use --force to run anyway.')
sys.exit(1) sys.exit(1)
command_name = "mypy" if not args.daemon else "dmypy" command_name = "mypy" if (args.no_daemon or args.version) else "dmypy"
# Use zulip-py3-venv's mypy if it's available. # Use zulip-py3-venv's mypy if it's available.
VENV_DIR = "/srv/zulip-py3-venv" VENV_DIR = "/srv/zulip-py3-venv"
@ -80,10 +80,10 @@ if args.quick:
extra_args.append("--quick") extra_args.append("--quick")
mypy_args = extra_args + python_files + pyi_files mypy_args = extra_args + python_files + pyi_files
if args.daemon: if args.no_daemon:
rc = subprocess.call([mypy_command, 'run', '--'] + mypy_args)
else:
rc = subprocess.call([mypy_command] + mypy_args) rc = subprocess.call([mypy_command] + mypy_args)
else:
rc = subprocess.call([mypy_command, 'run', '--'] + mypy_args)
if rc != 0: if rc != 0:
print("") print("")