-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Support 'on'/'off' for type ignores #9483
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
Related: #9484 |
Related, also mentions |
Awesome, I didn't know Sidenote: |
Could you send a PR that updates the docs to your liking? I agree that phrasing is odd -- it comes from the early days of discussion about PEP 484, when there appeared to be a substantial (or at least vocal) minority of Python users who didn't want to use annotations for types because they already had some other (ab)use in mind. |
Sometimes it's impossible to put
# type: ignore
on the offending line - e.g. because it's a multiline string, and there's nowhere you can put the comment outside the string that mypy will recognise. Or more generally, there might be a whole block of code for which mypy has a bunch of spurious complaints, so putting in dozens of# type: ignore
s is a bit noisy.The only other option today is to have mypy ignore the entire file, but that has nasty ramifications - beyond just killing type checking for what might be 99% checkable, it also makes any imports of that file invalid, and so you have to spread ignore directives out like a messy spiderweb.
Thus, it'd be great if one could do e.g.
# type: ignore on
and# type: ignore off
, so that the scope could be controlled precisely.The text was updated successfully, but these errors were encountered: