-
Notifications
You must be signed in to change notification settings - Fork 771
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
Yellow underline with reportUndefinedVariable when creating __eq__ method on dataclass #491
Comments
I believe this is the same as microsoft/pyright#1098 and should be fixed in our release today. |
This is related to semantic highlighting, if you set the following the message will go away on a reload.
|
@jakebailey, are you able to repro this in pylance with the latest code? |
Yes, that's what the screenshots are of above, just our code at the latest. This repro is consistent, at least from my testing. I have a "fix" that just suppresses all diagnostics during the semantic token walk which I think would solve this once and for all, so long as the semantic token pass isn't produce diagnostics that the background isn't. |
Yeah, that's not the right fix. That will simply suppress what is a real bug. This is likely a real bug in the type evaluator triggered by a particular order of evaluation that the semantic token code is using. If I can find a repro, I should be able to fix it in short order. I wasn't able to repro the other similar bug with the latest code. |
IIRC we disable the background thread on debug (because node doesn't make it easy to debug it), and that's where the diagnostics / semantic tokenization happens. That probably doesn't help in trying to find the issue. 🙁 |
Yeah, I temporarily disable the background analysis when I'm debugging issues like this. |
Oh, what am I saying, I ran this in debug mode (I didn't make a VSIX or anything), so there's at least some hope. |
This was a bug in the semantic token provider. It was calling the type evaluator to evaluate the type of an expression, but it wasn't passing an expression node. I've made the type evaluator more resilient so it can handle this case. This was an easier and more robust way to fix this than finding all the places where the caller was passing a non-expression node. The fix will be in the next release of pylance. |
This issue has been fixed in version 2020.10.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020102-21-october-2020 |
Environment data
Expected behaviour
No yellow underline when defining
__eq__
method on a dataclassActual behaviour
Yellow underline appears, with
"__eq__" is not definedPylance (reportUndefinedVariable)
Code Snippet / Additional information
Yellow underline appears on dataclass class, but not on non-dataclass class.
The text was updated successfully, but these errors were encountered: