-
-
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
Getting Invalid "type: ignore" comment reports from 3rd party library code #12299
Comments
Agreed that this isn't a great user experience. mypy treats invalid type ignore comments like it would syntax errors. Maybe we should make these non-blocking, so a per-module ignore_errors could work. What do you mean by pyright-style type ignore comments? Is there a reference for that? Your best workaround for now is something like:
|
I think that "pyright-style" is meant to imply "a form that pyright accepts". Since PEP 484 isn't very specific about what forms of I think we have a couple of options here:
I don't have a strong opinion, but I have a slight preference for option 1 because I think there's utility in allowing additional information after the |
Note that mypy allows the Changing mypy to be less strict here makes sense to me; user intention is clear modulo typos like |
Blocking errors are a bad user experience and there's no reason for this one to be one / there is another code path for invalid type ignores that is non-blocking. Fixes half of python#12299. The half it doesn't fix is that ideally users shouldn't be getting these warnings from third party libraries. Also see python#12162 (comment) But that's for another PR
Blocking errors are a bad user experience and there's no reason for this one to be one / there is another code path for invalid type ignores that is non-blocking. Fixes half of #12299. The half it doesn't fix is that ideally users shouldn't be getting these warnings from third party libraries. Also see #12162 (comment) But that's for another PR
Bug Report
3rd party library I am using recently added pyright style
type: ignore
comments. I have no control on those. Example: https://github.com/Rapptz/discord.py/blob/1c4dca431db375a24820abd23f91796dcf01ad32/discord/app_commands/namespace.py#L124For some reason mypy complains about these instead of analyzing my code. Shouldnt bad comments in 3rd party code be treated as just
type: ignore
?To Reproduce
python -m venv .venv && source .venv/bin/activate
pip install mypy 'git+https://github.com/Rapptz/discord.py@a909c1ff069b1bdb332b7f3b01ef1c4b8a3a3a15'
main.py
:mypy main.py
Expected Behavior
mypy should report errors in my code
Actual Behavior
mypy ignores errors in my code and instead complains about bad
type: ignore
comments in 3rd party library.Only if I remove
import discord
line, mypy reports error in file.Your Environment
0.931
mypy.ini
(and other config files): none3.10.2
The text was updated successfully, but these errors were encountered: