UPDATE
This issue is resolved in PyCharm 2017.2.
def foo(x):
return x / (60 * 60)
z = 1
y = 2
bar = 0 if y == 0 else z / y
foo(bar)
This leads to the fact that PyCharm 2017.1.4 with quite a few analyzer default settings (I believe) shows the following warning:
The expected type '{__div__}', instead is 'Union [int, float]'.
This check detects type errors in function call expressions. Due to dynamic dispatch and duck printing, this is possible in a limited but useful amount of cases.
Now, of course, Python does not have a static type check, but here it is obvious that barthere will always be inteither float(and PyCharm understands this as obvious in the got Union[int, float]warning above).
, PyCharm , , int float __div__, - , ?
UPDATE
, foo return x * 60 * 60, , PyCharm x __mul__.
2
foo return float(x) / (60 * 60), , , x int float, .
PyCharm.