-
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
False-positive cannot assign expression to yield type (with TypeVar, overload, and Union) #1809
Comments
Thanks for the report. |
Thanks, this will be fixed in the next release. The code that handles |
This issue has been fixed in version 2021.9.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202192-16-september-2021 |
This is still an issue when modified slightly: from typing import TypeVar, Iterator
T1 = TypeVar("T1", bound="X")
T2 = TypeVar("T2", bound="X")
class X:
element_list: list["X"]
def return_iter(
self, klass: type[T1] | tuple[type[T1], type[T2]] | tuple[type[T1], ...]
) -> Iterator[T1] | Iterator[T2]:
for item in self.element_list:
if isinstance(item, klass):
yield item # error Added |
You're right — I didn't handle the required special casing for open-ended tuples (the |
Thank you @erictraut! I appreciate how fast you and the team address these issues. It's amazing to see pylance and pyright getting better. |
Environment data
Expected behaviour
no error
Actual behaviour
Logs
--
Code Snippet / Additional information
Mypy output
no error
The text was updated successfully, but these errors were encountered: