-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
mypy runs forever with colour-science #12225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Cross-posting here if helpful: I have just checked on my end, without any (colour-49B8_mty-py3.9) Eris:colour kelsolaar$ time mypy --show-error-codes --warn-unused-ignores --warn-redundant-casts --install-types --non-interactive -p colour
colour/io/image.py:119: error: Unused "type: ignore" comment
colour/io/image.py:119: error: Module has no attribute "float128"; maybe "float32" or "float16"? [attr-defined]
colour/io/image.py:135: error: Unused "type: ignore" comment
colour/io/image.py:135: error: Module has no attribute "float128"; maybe "float32" or "float16"? [attr-defined]
Found 4 errors in 1 file (checked 532 source files)
real 2m30.199s
user 2m29.421s
sys 0m2.268s
PS: Those 4 errors are expected on my platform, I'm running with a MacBook M1. |
It may be that cleaning the mypy cache has solved this for me. |
This issue keeps coming back in various forms. While reporting #12442, I think I confirmed that
I have no idea what an SCC is and whether one with size 302 is good or not, but it's by far the biggest reported. Maybe it helps someone to understand what is going on. |
I ran the following code on two systems across three installations (Windows 10 Python 3.10, Linux Python 3.9 and 3.10):
Windows finished in close to 9 minutes (Core i7-9750H), Linux in 22 and 23 minutes (Core i9-7900X). All color-science 0.4.1, mypy 0.942. So it's not "forever", but still very long (and when using |
@KelSolaar what do you think would be good way to typecheck the whole package for comparison purposes? The following does not work with 0.3.16:
I also tried this, which does not work, either:
(but this explains why I saw such drastic runtime increases with What else can I provide to find out what makes |
The released Colour 0.3.16 does not have any typing support at all, it was only added to 0.4.x. I have personally not experienced any long type checking times locally but they do vary on CI though: https://github.com/colour-science/colour/actions/workflows/continuous-integration-static-type-checking.yml |
Are you sure? I checked couple of jobs that took between 12min and 1h34min, and the actual type checking always takes some 11-15 minutes - and that includes the So it doesn't look that bad on CI IMO, or am I missing some more |
It hurts me to have to say that, but a useful workaround in
I guess this skips type checking for |
I profiled a mypy run targeting colour and it seems likely that most of the time is spent on operations involving large union types. There are mypy operations on union types that are O(n**2), which has been known to cause slow type checking. It's probably not too difficult to make this better. We already have some related optimizations, but clearly they don't seem to help here. |
The latest GitHub master seems to be marginally faster with colour-science than 0.942 (around 20%). I did some prototyping, and caching the results of Caching would be somewhat non-trivial to implement properly, instead of just prototyping. Some of our current |
With mypy 0.950, Windows is down to less than 5 minutes, and Linux is down to 8 minutes. This is much better already! |
Thanks for reporting! mypy 0.960 made several further improvements to perf. We have #12526 as an issue to track improvements to union simplification, so closing this out |
I added colour-science to mypy_primer today, so regressions on the codebase for pyright or mypy will now be flagged. I noticed that colour-science has switched to pyright, but latest mypy runs about 4x faster than pyright does on colour-science, so wondering if I'm missing something. Edit: nice, looks like posting this got Eric to make pyright faster! microsoft/pyright#9115 :-) |
Bug Report
mypy never finishes with
colour-science==0.4.0
.To Reproduce
Expected Behavior
Finish within ~2 minutes
Actual Behavior
Does not finish
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: