-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Feature Request] Mypy type checking #1121
Comments
I think having both is better. Once we fix all the issues of adding mypy, there is little to no cost in keeping both. Very occasionally they conflict, but normally the solution is fairly simple. |
I am happy to contribute to adding mypy as I have done this for imitation already and I have some experience in how to do and not do things. Some of the takeaways I would say are:
Additionally, one could also check the diff of ignored files so when e.g. adding new classes these don't introduce more errors. But I would not expect this to be very useful given that the project is quite mature & unlikely to have significant API changes in the near future (afaik), and it seems hard to set up. |
This roadmap sounds reasonable.
#780 introduces changes to a significant number of files, but I think these changes should not interfere too much. |
oh nice, I didn't know that syntax. Yes, we do a lot of
what is the reasoning behind?
sounds good =) |
Pytype and mypy work in fundamentally different ways. Pytype tries to infer types and is generally lenient. Mypy relies on annotations exclusively and is generally strict. Also see https://docs.google.com/presentation/d/1GYqLeLkknjYaYX2JrMzxX8LGw_rlO-6kTk-VNPVG9gY/htmlpresent |
Do we want this strict typing? I would swing 75% for a yes. |
What is the most effective process in your opinion?
This determines how you specify the ignores in For 1. [mypy]
disable_error_code = error-code1, error-code2, error-code3 For 2. [mypy]
exclude = (?x)(
file1.py
| file2.py
) For 3. [mypy-file1]
disable_error_code = error-code1, error-code2
[mypy-file2]
disable_error_code = error-code2, error-code3 |
I would prefer that one but I don't know how easy it is compared to option 2. |
I don't think it makes much sense to ignore a certain type of error across the entire codebase. In my experience doing this for It also ensures that whole pieces of the API are fully type safe, rather than potentially having bugs across the entire API until everything is fixed. Also, ignoring an error type for all files prevents the type checker from detecting new errors that are added in clean files. And because the codebase is quite large, I expect that the vast majority of possible error types are somewhere in the codebase. So ignoring them all would make adding mypy basically useless. |
So we would go with option 3? The only problem is that the setup.cfg file might be a bit ugly... But it allows you to take the best of the other two options. |
I don't mind either way. We can go with 3 for now, if it gets too messy we can switch to 2. |
i thought that @Rocamonde described option 2, no?
I was expecting the opposite actually (that's why I was suggesting option 1). |
Let's do the opposite: we go for option 2 and if fixing is too hard, we switch to 3. Ok for you? |
🚀 Feature
Use mypy as the type checker.
Follow-up of #1119 (comment)
Motivation
Currently, type checking is done with pytype. It seems that many errors are not correctly detected: #894 #1027 #1039 #1040 #1117 #1119
Pitch
Replace pytype by mypy.
Or just add mypy.
Alternatives
No response
Additional context
This would require a lot of changes, in particular removing the use of
None
for undefined variables:current usage
what should be done, according to PEP526 (if I understand properly)
Checklist
The text was updated successfully, but these errors were encountered: