Curriocity about weird type inference #6275
martinkozle
started this conversation in
General
Replies: 1 comment 2 replies
-
To simplify the case a little bit: Code sample 3 in pyright playground def f(a):
if isinstance(a, int):
return a
return None
b = f(3)
reveal_type(b) Output:
Code sample 4 in pyright playground def f(a):
if isinstance(a, int):
return a
elif isinstance(a, tuple):
return a
return None
b = f(3)
reveal_type(b) Output:
Why does adding an |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Why does adding a tuple
isinstance
check, which I would guess should have no effect here, change the inferred type so much?Code sample 1 in pyright playground
Output:
Code sample 2 in pyright playground
Output:
Beta Was this translation helpful? Give feedback.
All reactions