-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Warn about unused '# type: ignore' comments #1695
Conversation
The results on mypy itself, for those curious:
|
I can't wait to use this! Unfortunately there's also #1294 which someone at the sprints was going to tackle (though they haven't sent a PR yet). Wouldn't it be confusing if these notes appeared at the end and out of order? (Then again, out of order is better than not at all.) |
I made a separate PR (#1705) for redundant casts since that one is actually much simpler. I'm happy to have these two flags controlled by the same command-line option if someone wants to suggest a name :)
I thought about that PR, but I'd rather not block this on waiting for that one, and as you say a confusing message order is better than not having the messages at all. With that PR it'd certainly make sense to generate the unused |
Curious, what is this waiting on? I really want this feature! |
Oh, thanks for the reminder about this one. When I wrote this I didn't know how to write tests that set build flags, but I do now (using |
Please do!
|
ca2912b
to
116bedf
Compare
This still needs new tests (will add them a bit later) but I'm much happier with this version which handles |
116bedf
to
76817e3
Compare
OK, this should be ready to go except that one of the new tests fails for now; I filed #1737 to fix it separately because I'm not 100% sure I understand what is going on there. That PR should be landed (or otherwise resolved somehow) before this one. |
This commit also simplifies the handling of ignored_lines slightly, setting them once in the Errors object for each file file after it is parsed. Fixes python#1345 and python#1739.
76817e3
to
01f5d3f
Compare
There's a problem with this PR that we discovered today: #1911. In an attempt to make it so that you can use |
Well that's what I intended and I think what the old behavior was (though maybe not with the fast parser): see discussion at #1737. But the new behavior seems fine to me too. |
Oh dear. I bisected but it never occurred to me that this would differ
between the old and the new parser.
It also seems I disagree with my past self -- I currently strongly feel
it's surprising that `import x # type: ignore` never looks at x (or only
when it's already been imported without an ignore elsewhere).
So I'd still like to see this fixed, for both the old and the new parser.
Seems you're fine with that. Thanks for the additional color!
|
Still needs tests and some cleanup.