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
Mypy should support multiple isinstance checks in a condition:
def f(x: A, y: A) -> None:
if isinstance(x, B) and isinstance(y, B):
# Types of both x and y should be B here, but currently only x is B
...
class A: pass
class B(A): pass
I think find_isinstance_check should effectively return a tuple of Tuple[Dict[Node, Tuple[Type, Type]], int] where the int is the old kind. My impression is that the result kind, contrary to the documentation, should represent whether the condition is always true whether than rather the isinstance is always true (based on what we do in the and case currently). If thats not true, it would go inside the Dict.
My impression is that the result kind, contrary to the documentation, should represent whether the condition is always true whether than rather the isinstance is always true (based on what we do in the and case currently).
Yeah, that's right. I would probably go with Tuple[Dict[Node, Type], Dict[Node, Type], int], for the return type, though.
Actually, it might be better to be Tuple[Optional[Dict[Node, Type]], Optional[Dict[Node, Type]]] with no kind at all -- if a component is None, then that branch of the conditional cannot happen. If it's not None, then you update the binder using the component. This would avoid the need for the ISINSTANCE_ enum entirely.
Activity
jhance commentedon Oct 10, 2015
I think
find_isinstance_checkshould effectively return a tuple ofTuple[Dict[Node, Tuple[Type, Type]], int]where theintis the oldkind. My impression is that the resultkind, contrary to the documentation, should represent whether the condition is always true whether than rather theisinstanceis always true (based on what we do in theandcase currently). If thats not true, it would go inside theDict.ecprice commentedon Oct 10, 2015
Yeah, that's right. I would probably go with Tuple[Dict[Node, Type], Dict[Node, Type], int], for the return type, though.
Actually, it might be better to be Tuple[Optional[Dict[Node, Type]], Optional[Dict[Node, Type]]] with no kind at all -- if a component is None, then that branch of the conditional cannot happen. If it's not None, then you update the binder using the component. This would avoid the need for the ISINSTANCE_ enum entirely.
Support multiple isinstance in a single if.
Support multiple isinstance in a single if.
Support multiple isinstance in a single if.
Support multiple isinstance in a single if.