-
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
Pylance doesn't resolve TypeVar type correctly #1165
Comments
Thanks for posting this sample. I'll look into it in more detail. If you have other instances where you feel a false positive is generated — especially in "basic" type checking mode (as opposed to "strict" mode), please file bugs on those, and we'll look at them too. |
Will do, thanks! |
Thanks again for the bug report. This was a tricky bug in pyright, the type checker that powers pylance. It involved three of the most complex piece of code in the type checker: logic to handle constrained TypeVars, type narrowing for "isinstance" calls, and binary operations (in this case, a I've fixed the bug and beefed up the unit tests in this area. The fix will be in the next release of pylance. |
Brilliant, thanks! |
We'll leave the bug open until the next release. |
This issue has been fixed in version 2021.4.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202142-21-april-2021 |
Environment data
Code Snippet / Additional information
I am using basic type checking (not strict).
Expected behaviour
I would expect no type issues with the above.
Actual behaviour
Both 2 * x and 3 * x are underlined.
2 * x says: Expression of type "DataFrame" cannot be assigned to return type "DfOrSer@f"
Type "DataFrame" cannot be assigned to type "DfOrSer@f" Pylance(reportGeneralTypeIssues)
3 * x says: Expression of type "Series[Unknown]" cannot be assigned to return type "DfOrSer@f"
Type "Series[Unknown]" cannot be assigned to type "DfOrSer@f" Pylance(reportGeneralTypeIssues)
I feel that generally the type checker catches too many false positives, which is reducing its utility in coding.
The text was updated successfully, but these errors were encountered: