Skip to content
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

Run static typing checks #1222

Open
astrojuanlu opened this issue Aug 23, 2022 · 2 comments
Open

Run static typing checks #1222

astrojuanlu opened this issue Aug 23, 2022 · 2 comments
Labels
internal Something that does not affect users directly, e.g. code quality.

Comments

@astrojuanlu
Copy link
Contributor

#1216 started adding some type hints to the codebase, as requested in #450. However, to my knowledge, we are not actually verifying if those hints are correct.

One of the possible type checkers is MyPy (Dropbox). It would be nice to add MyPy as part of pre-commit - however, as far as I understand, each hook runs in its own virtual environment, and therefore doesn't have the dependencies installed. This is problematic to run MyPy in "strict" mode, since one would have to --ignore-imports. There's more background here https://jaredkhan.com/blog/mypy-pre-commit

At some point I was using pytest-mypy, but I was hitting realpython/pytest-mypy#123 too often so now I default to running mypy src tests just before pytest.

Other checkers:

I personally only have experience with MyPy.

@yannickperrenet
Copy link
Contributor

yannickperrenet commented Aug 24, 2022

I use pyright as my language server and have only occasionally used it as a type checker. I know that pyright can sometimes be rather slow so it would be something we have to investigate.

On another note, I do like the benefit of type checkers but I don't want to be in a spot where we are spending more time fixing types than improving the product. I guess we have to try it before we know it.

@astrojuanlu
Copy link
Contributor Author

On another note, I do like the benefit of type checkers but I don't want to be in a spot where we are spending more time fixing types than improving the product. I guess we have to try it before we know it.

This is a very real concern. In my experience, MyPy in strict mode can be pretty picky and annoying. The good news is that these tools are usually highly configurable, it's a matter of finding the sweet spot.

@yannickperrenet yannickperrenet added the internal Something that does not affect users directly, e.g. code quality. label Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Something that does not affect users directly, e.g. code quality.
Projects
None yet
Development

No branches or pull requests

2 participants