title: The day PyCharm thought int / float does not implement __div__
body: <p><strong>UPDATE</strong>
  This issue is solved in PyCharm 2017.2</p>
  <pre><code>def foo(x):
      return x / (60 * 60)
  
  z = 1
  y = 2
  bar = 0 if y == 0 else z / y
  
  foo(bar)
  </code></pre>
  <p>This causes PyCharm 2017.1.4 with pretty much default analyzer settings (I believe) show the following warning:</p>
  <blockquote>
  <p>Expected type <code>'{__div__}'</code>, got 'Union[int, float]' instead.</p>
  <p>This inspection detects type errors in function call expressions. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases</p>
  </blockquote>
  <p>Now, of course Python doesn't have static type checking, but it is obvious here that <code>bar</code> will always be <code>int</code> or <code>float</code> (and PyCharm understands it as evident by <code>got Union[int, float]</code> in the above warning).</p>
  <p>So, is this a bug in PyCharm with this specific use case in which it fails to see that <code>int</code> and <code>float</code> do implement <code>__div__</code>, or is there something else that I'm missing here?</p>
  <p><strong>UPDATE</strong></p>
  <p>Oddly enough, if <code>foo</code> is modified to <code>return x * 60 * 60</code> the warning goes away and PyCharm doesn't warn about <code>x</code> not implementing <code>__mul__</code>.</p>
  <p><strong>UPDATE 2</strong></p>
  <p>Changing <code>foo</code> to <code>return float(x) / (60 * 60)</code> obviously makes the warning disappear, but <code>x</code> is already inferred as <code>int</code> or <code>float</code> as evident by the warning itself.</p>
  <p>Definitely seems like a bug in PyCharm.</p>