mirror of https://github.com/zulip/zulip.git
mypy: Remove daemon mode.
mypy in daemon mode takes some 400 MiB of memory, and cannot follow imports of type-annotated third-party packages; meanwhile, non-daemon mode is no longer nearly as slow as it once was. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
9c49049c9e
commit
99904527f5
|
@ -48,14 +48,6 @@ To run mypy on Zulip's python code, you can run the command:
|
||||||
|
|
||||||
tools/run-mypy
|
tools/run-mypy
|
||||||
|
|
||||||
This will take a while to start running, since it runs mypy as a
|
|
||||||
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 --no-daemon
|
|
||||||
|
|
||||||
Mypy outputs errors in the same style as a compiler would. For
|
Mypy outputs 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:
|
||||||
|
|
||||||
|
@ -118,10 +110,6 @@ everything in the third-party module as an `Any`, which is the right
|
||||||
model (one certainly wouldn't want to need stubs for everything just
|
model (one certainly wouldn't want to need stubs for everything just
|
||||||
to use `mypy`!), but means the code can't be fully type-checked.
|
to use `mypy`!), but means the code can't be fully type-checked.
|
||||||
|
|
||||||
**Note**: When editing stubs, we recommend using
|
|
||||||
`tools/run-mypy --no-daemon`, because the mypy daemon's caching
|
|
||||||
system has some bugs around editing stubs that can be confusing.
|
|
||||||
|
|
||||||
## `type_debug.py`
|
## `type_debug.py`
|
||||||
|
|
||||||
`zerver/lib/type_debug.py` has a useful decorator `print_types`. It
|
`zerver/lib/type_debug.py` has a useful decorator `print_types`. It
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
# NOTE: When editing stubs, we recommend using `tools/run-mypy --no-daemon`,
|
|
||||||
# because the mypy daemon's caching system has some bugs around editing stubs
|
|
||||||
#
|
|
||||||
# See https://zulip.readthedocs.io/en/latest/testing/mypy.html#mypy-stubs-for-third-party-modules
|
# See https://zulip.readthedocs.io/en/latest/testing/mypy.html#mypy-stubs-for-third-party-modules
|
||||||
# for notes on how we manage mypy stubs.
|
# for notes on how we manage mypy stubs.
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,7 @@ 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
|
||||||
# We run mypy without daemon mode, since that's faster given that
|
./tools/run-mypy
|
||||||
# we're only going to run it once, and catches more errors since
|
|
||||||
# daemon mode doesn't follow package imports.
|
|
||||||
./tools/run-mypy --no-daemon
|
|
||||||
|
|
||||||
./tools/test-migrations
|
./tools/test-migrations
|
||||||
./tools/setup/optimize-svg
|
./tools/setup/optimize-svg
|
||||||
|
|
|
@ -27,8 +27,6 @@ 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('--no-daemon', action='store_true',
|
|
||||||
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")
|
||||||
parser.add_argument('-a', '--all', action='store_true',
|
parser.add_argument('-a', '--all', action='store_true',
|
||||||
|
@ -39,7 +37,7 @@ args = parser.parse_args()
|
||||||
|
|
||||||
assert_provisioning_status_ok(args.force)
|
assert_provisioning_status_ok(args.force)
|
||||||
|
|
||||||
command_name = "mypy" if (args.no_daemon or args.version) else "dmypy"
|
command_name = "mypy"
|
||||||
|
|
||||||
# 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"
|
||||||
|
@ -75,15 +73,7 @@ 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.no_daemon:
|
|
||||||
rc = subprocess.call([mypy_command] + mypy_args)
|
rc = subprocess.call([mypy_command] + mypy_args)
|
||||||
else:
|
|
||||||
mypy_args += ["--follow-imports=skip"]
|
|
||||||
rc = subprocess.call([mypy_command, "status"], stdout=subprocess.PIPE)
|
|
||||||
if rc != 0:
|
|
||||||
print("Starting mypy daemon, this will take a minute...")
|
|
||||||
sys.stdout.flush()
|
|
||||||
rc = subprocess.call([mypy_command, 'run', '--'] + mypy_args)
|
|
||||||
|
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
print("")
|
print("")
|
||||||
|
|
Loading…
Reference in New Issue