Add type-checking
- Add .mypy.ini
- Add mypy to pre-commit
- Add mypy to GitHub Actioons
- [X] Starts working on #2173
- [X] Tests added
- [X] Release note added (or unnecessary)
I don't understand why we would add a GHA workflow instead of just adding mypy to the pre-commit config. The latter should suffice.
I also suggest that we put the mypy config into the pyproject.toml file.
Thanks @szabgab for getting this started!
I've moved the mypy configuration to pyproject.toml and rebased the PR.
I still could not figure out why does mypy fail on the pre-commit.ci while passes on GHA. That's the reason I kept GHA.
I still could not figure out why does mypy fail on the pre-commit.ci while passes on GHA. That's the reason I kept GHA.
Because pre-commit creates isolated environments. You’d need to duplicate all dependencies in .pre-commit-config.yaml to make it work, like here:
https://github.com/scverse/fast-array-utils/blob/6af5d9a339a78604ff62230e6462f3a7a94fec3f/.pre-commit-config.yaml#L24-L41
It seems that rebasing to main broke mypy. Specifically this commit 470db9cc09bf5861234dbf0d9cb575cd3b68c12d
The class name[] syntax seems something that mypy does not accept.
Starting with version 1.12, mypy supports this syntax: https://mypy.readthedocs.io/en/latest/changelog.html#support-python-3-12-syntax-for-generics-pep-695
I see an internal error, so it’s for sure a mypy bug though!
Seems like it’s either fixed on master or the “49 files” mypy checks are docs and stuff. No way it just succeeds.
So maybe you could go ahead and merge this now.
We might later move the mypy run to the pre-commit hook, though it seems it is also disabled on fast-array-utils