Closed minmax closed 1 month ago
I think the new behavior is arguably more correct than the old behavior because the type variable T_co
is going unsolved in this case and therefore should probably result in an Unknown
type.
I can also see how the old behavior would be preferable in your use case.
I did an experiment and restored the old behavior where pyright attempts to use constraints from the full union rather than preferring a single subtype of the full union. This produces a bunch of extra false positive errors in many code bases. This was the reason I made the change in the first place.
I'll need to think about this a bit more, but my inclination at this point is to stick with the new behavior.
I added some additional heuristics that allow me to strike a balance between the old behavior and the new behavior. This allows your use case to work while also addressing the other bugs that prompted this change. This will be included in the next release.
This is addressed in pyright 1.1.373.
After updating pyright 1.1.371 -> 1.1.372, union resolution start to failed in some strange case.
I found how to fix this, but I'm not sure if the error behavior is correct. So if i change
Callable[[E_co], Err[F]]
toCallable[[E_co], Result[Never, F]]
, the error goes away.ps in real code i use result lib with Ok, Err and Result.