Add mypy check in pre-commit config
Is your feature request related to a problem? Please describe.
Not really a problem, but I think it might be good for developers.
Maybe we should add mypy to pre-commit, not it will not run automatically when committing. And cloud CI can report type error even when committing successfully at local machine.
I am not sure if this is a problem to others, because including more checks in pre-commit also increase the time cost before a commit and can frustrate people I guess.
Describe the solution you'd like
maybe add this to pre-commit config
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context about the feature request here.
I am fine with it, but it can be slow as you noted. Have you tried it locally? If yes, what's the usual wait time when committing?
In a related effort, I am thinking about switching to Astral's toolchain since a few months, and the lack of a mypy-like replacement held me, but with the introduction of https://github.com/astral-sh/ty that might be the good time to try the migration. If ty is as fast as it claims to be, that might be fine for commit times.
I am fine with it, but it can be slow as you noted. Have you tried it locally? If yes, what's the usual wait time when committing?I
I haven't try it locally before creating this issue. I usually run mypy src/ manually and it takes several seconds to finish.
After trying https://github.com/pre-commit/mirrors-mypy, I observe inconsistent output, i.e., the pre-commit runs with many errors (seems to be false-positive) but mypy src/ returns no error. I have checked that the versions of mypy are consistent (v1.15.0), maybe there're some weird issues when running mypy in pre-commit consider it runs in a isolated environment: https://github.com/pre-commit/pre-commit/issues/1580.
Anybody interested in this can have a try in my experiment branch
If ty is as fast as it claims to be, that might be fine for commit times.
That seems to be a promising solution, I'll try it later if nobody takes this issue
I haven't try it locally before creating this issue. I usually run mypy src/ manually and it takes several seconds to finish.
Yes, this has been my experience with mypy too. It can take some time for mypy to run.
I observe inconsistent output, i.e., the pre-commit runs with many errors (seems to be false-positive) but mypy src/ returns no error
It is also possible that pre-commit might not be taking the mypy configuration settings in pyproject.toml into consideration. I have had this happen with ruff in another project.
I think this issue can be closed or migrated in favor of @purva-thakre 's recent effort in migrating to Astral's toolchain?
I think this issue can be closed or migrated in favor of @purva-thakre 's recent effort in migrating to Astral's toolchain?
We are missing a specific issue to try out ty from Astral's toolchain. Maybe this issue would be the right one to do that?
We could also think about switching to uv if we want to completely migrate to Astral's toolchain. https://docs.astral.sh/uv/
We could also think about switching to
uvif we want to completely migrate to Astral's toolchain. https://docs.astral.sh/uv/
That would make sense in my opinion
Do we want to try & implement ty now or wait until it is stable?
Do we want to try & implement
tynow or wait until it is stable?
If ty does not miss any critical features, I prefer to use it now because everything from astral is truly amazing.
Indeed, everything from astral is amazing.
@Zhaoyilunnn Do you want to try implementing this?
Indeed, everything from astral is amazing.
@Zhaoyilunnn Do you want to try implementing this?
I won't be able to work on TQEC until next month.. so it would be nice if you or anybody can fix this issue earlier