-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 of incompatible types (about generic protocol) since 1.1.337 #6767
Comments
If the sample code is modified as below -- from typing import Generic, Protocol, TypeVar
V_co = TypeVar("V_co", covariant=True)
class C(Generic[V_co]):
def f(self, /) -> V_co: ...
class P0(Protocol[V_co]):
def f(self, /) -> V_co: ...
class P1(Protocol[V_co]):
def f(self, /) -> V_co: ...
def f(
v0: C[C[object]],
v1: C[P0[object]],
v2: P1[P0[object]],
):
_ = v0, v1, v2
if 0:
v1 = v0
elif 0:
v2 = v1
elif 0:
v2 = v0 No error is reported. So I suspict there is some data pollution among generic types of a same protocol. |
Thanks, I really appreciate the work you put into writing great bug reports. I've narrowed the regression to this commit. The issue is related to the constraint solver, which is conflating the type variable of the "inner" |
I'm glad to help. |
…tions that involve nested protocols (such as `P[P[T]]`). This addresses #6767.
This is addressed in pyright 1.1.364. |
Describe the bug
See sample code below.
In function
f
,v1
can be assigned tov0
andv2
can be assigned tov1
, butv2
cannot be directly assigned tov0
.Code or Screenshots
Pyright Playground
VS Code extension or command-line
This issue appears since version 1.1.337. It doesn't appear with version from 1.1.292 through 1.1.336.
The text was updated successfully, but these errors were encountered: