Open
Description
(Not sure if it should be here or in typing)
Consider this function:
def f():
return "hello"
def g(x):
if x: return A(1)
else: return A(2)
f
obviously (without any deep analysis) returns str
, and g
returns A. Why not use this information? This pattern is very common, and taking advantage of it can help in precise checking and remove clutter (for example -> Union[Tuple[int, int, str], Tuple[int, str, bool]]
).
I propose treating calls to functions whose return expressions consists solely of literals and constructor calls as if they were declared with the returned type (join or union of the return types).