Skip to content

Commit 9990452

Browse files
andersktimabbott
authored andcommitted
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 <[email protected]>
1 parent 9c49049 commit 9990452

File tree

4 files changed

+3
-31
lines changed

4 files changed

+3
-31
lines changed

docs/testing/mypy.md

-12
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ To run mypy on Zulip's python code, you can run the command:
4848

4949
tools/run-mypy
5050

51-
This will take a while to start running, since it runs mypy as a
52-
long-running daemon (server) process and send type-checking requests
53-
to the server; this makes checking mypy about 100x faster. But if
54-
you're debugging or for whatever reason don't want the daemon, you can
55-
use:
56-
57-
tools/run-mypy --no-daemon
58-
5951
Mypy outputs errors in the same style as a compiler would. For
6052
example, if your code has a type error like this:
6153

@@ -118,10 +110,6 @@ everything in the third-party module as an `Any`, which is the right
118110
model (one certainly wouldn't want to need stubs for everything just
119111
to use `mypy`!), but means the code can't be fully type-checked.
120112

121-
**Note**: When editing stubs, we recommend using
122-
`tools/run-mypy --no-daemon`, because the mypy daemon's caching
123-
system has some bugs around editing stubs that can be confusing.
124-
125113
## `type_debug.py`
126114

127115
`zerver/lib/type_debug.py` has a useful decorator `print_types`. It

stubs/stripe/__init__.pyi

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# NOTE: When editing stubs, we recommend using `tools/run-mypy --no-daemon`,
2-
# because the mypy daemon's caching system has some bugs around editing stubs
3-
#
41
# See https://zulip.readthedocs.io/en/latest/testing/mypy.html#mypy-stubs-for-third-party-modules
52
# for notes on how we manage mypy stubs.
63

tools/ci/backend

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ set -x
1717
# We run mypy after the backend tests so we get output from the
1818
# backend tests, which tend to uncover more serious problems, first.
1919
./tools/run-mypy --version
20-
# We run mypy without daemon mode, since that's faster given that
21-
# we're only going to run it once, and catches more errors since
22-
# daemon mode doesn't follow package imports.
23-
./tools/run-mypy --no-daemon
20+
./tools/run-mypy
2421

2522
./tools/test-migrations
2623
./tools/setup/optimize-svg

tools/run-mypy

+2-12
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ parser.add_argument('--quick', action='store_true',
2727
help="pass --quick to mypy")
2828
parser.add_argument('-m', '--modified', action='store_true',
2929
help="check only modified files")
30-
parser.add_argument('--no-daemon', action='store_true',
31-
help="Start and run the mypy fine-grained incremental daemon")
3230
parser.add_argument('--scripts-only', action='store_true',
3331
help="only check extensionless python scripts")
3432
parser.add_argument('-a', '--all', action='store_true',
@@ -39,7 +37,7 @@ args = parser.parse_args()
3937

4038
assert_provisioning_status_ok(args.force)
4139

42-
command_name = "mypy" if (args.no_daemon or args.version) else "dmypy"
40+
command_name = "mypy"
4341

4442
# Use zulip-py3-venv's mypy if it's available.
4543
VENV_DIR = "/srv/zulip-py3-venv"
@@ -75,15 +73,7 @@ if args.quick:
7573
extra_args.append("--quick")
7674

7775
mypy_args = extra_args + python_files + pyi_files
78-
if args.no_daemon:
79-
rc = subprocess.call([mypy_command] + mypy_args)
80-
else:
81-
mypy_args += ["--follow-imports=skip"]
82-
rc = subprocess.call([mypy_command, "status"], stdout=subprocess.PIPE)
83-
if rc != 0:
84-
print("Starting mypy daemon, this will take a minute...")
85-
sys.stdout.flush()
86-
rc = subprocess.call([mypy_command, 'run', '--'] + mypy_args)
76+
rc = subprocess.call([mypy_command] + mypy_args)
8777

8878
if rc != 0:
8979
print("")

0 commit comments

Comments
 (0)