I find that mypy seems to invalidate its caches in a way that's very opaque to me. In my large company codebase below, I see runtimes like the following:
% time mypy --no-incremental <many files ...>
file/with/error.py:104: error: Unused "type: ignore" comment [unused-ignore]
Found 1 error in 1 file (checked 7552 source files)
Command exited with non-zero status 1
user: 256.59, sys: 7.09, real: 4:24.31. Max RSS 4885288kb
% time mypy <many files ...>
file/with/error.py:104: error: Unused "type: ignore" comment [unused-ignore]
Found 1 error in 1 file (checked 7552 source files)
Command exited with non-zero status 1
user: 224.25, sys: 4.24, real: 3:48.73. Max RSS 4172044kb
% time mypy <many files ...>
file/with/error.py:104: error: Unused "type: ignore" comment [unused-ignore]
Found 1 error in 1 file (checked 7552 source files)
Command exited with non-zero status 1
user: 156.00, sys: 3.37, real: 2:40.00. Max RSS 3570100kb
% time mypy <many files ...>
file/with/error.py:104: error: Unused "type: ignore" comment [unused-ignore]
Found 1 error in 1 file (checked 7552 source files)
Command exited with non-zero status 1
user: 66.77, sys: 2.61, real: 1:09.64. Max RSS 3112036kb
<fix>
% time mypy <many files ...>
Success: no issues found in 7552 source files
user: 67.14, sys: 2.53, real: 1:09.83. Max RSS 3115736kb
% time mypy <many files ...>
Success: no issues found in 7552 source files
user: 157.78, sys: 3.28, real: 2:41.42. Max RSS 3588304kb
% time mypy <many files ...>
Success: no issues found in 7552 source files
user: 67.82, sys: 2.66, real: 1:10.75. Max RSS 3093232kb
% time mypy <many files ...>
Success: no issues found in 7552 source files
user: 158.76, sys: 3.25, real: 2:42.34. Max RSS 3582952kb
Where two things stick out
Up until <fix> I am making no changes, and the runtime of mypy on the same content is slowly converging to 1 minute. But shouldn't the first run be slow, and every run after be exactly as fast? I wouldn't expect more than two values for runtimes
After fix, when the code is good and still not changing, runtimes are now bouncing between 1 & 2 minutes? If I am making no code changes, why would that happen?
When I try a --verbose, I see things like this sometimes: Processing SCC singleton (<my code>) as inherently stale with stale deps (attr attr.setters attrs pytest), which also seems very weird to me because those "stale deps" are in my venv, and those are also not changing (I would not expect packages, especially attrs & pytest to change).
So I'm wondering how things are getting marked as stale and forcing a reprocess...
Currently using mypy 1.11.2 (compiled: yes) with python 3.11 on debian 11
I find that mypy seems to invalidate its caches in a way that's very opaque to me. In my large company codebase below, I see runtimes like the following:
Where two things stick out
<fix>
I am making no changes, and the runtime of mypy on the same content is slowly converging to 1 minute. But shouldn't the first run be slow, and every run after be exactly as fast? I wouldn't expect more than two values for runtimesWhen I try a
--verbose
, I see things like this sometimes:Processing SCC singleton (<my code>) as inherently stale with stale deps (attr attr.setters attrs pytest)
, which also seems very weird to me because those "stale deps" are in my venv, and those are also not changing (I would not expect packages, especially attrs & pytest to change).So I'm wondering how things are getting marked as stale and forcing a reprocess...
Currently using mypy 1.11.2 (compiled: yes) with python 3.11 on debian 11