You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apologies in advance if this is a duplicate issue.
When I try type-checking this program, the final line is inferred to be unreachable. This was a bit surprising to me: I expected to get a "Revealed type is 'SupportsLookup'" note instead.
Somewhat curiously, if I make x be of type object instead of Parent, everything works as expected.
This seems a bit inconsistent to me. Assuming I'm not overlooking some type safety issue in my example, I think it'd be better to always narrow x to SupportsLookup regardless of how it's originally typed as long as the protocol doesn't directly conflict with any signatures defined in Parent.
Note: this issue is a simplification of the root cause of the mypyc error I had in #7917 -- my original version of make_indexing_replay_lookup_func had this issue.
The text was updated successfully, but these errors were encountered:
First of all mypyc doesn't support protocols yet, see mypyc/mypyc#586
About mypy issue itself, this is essentially a duplicate of #3830 (also tangentially related to #3827 and #3603).
This is actually not so obvious, we can't say that meet(SupportsLookup, Parent) is SupportsLookup because the latter is not a subtype of Parent, and we can't use Parent either. The best solution is probably to implement internal intersection-like generated TypeInfos that were proposed several times elsewhere, but they may be not easy to implement.
Apologies in advance if this is a duplicate issue.
When I try type-checking this program, the final line is inferred to be unreachable. This was a bit surprising to me: I expected to get a "Revealed type is 'SupportsLookup'" note instead.
Somewhat curiously, if I make
x
be of typeobject
instead ofParent
, everything works as expected.This seems a bit inconsistent to me. Assuming I'm not overlooking some type safety issue in my example, I think it'd be better to always narrow
x
toSupportsLookup
regardless of how it's originally typed as long as the protocol doesn't directly conflict with any signatures defined inParent
.Note: this issue is a simplification of the root cause of the mypyc error I had in #7917 -- my original version of
make_indexing_replay_lookup_func
had this issue.The text was updated successfully, but these errors were encountered: