title: Why does Pycharm's inspector complain about "d = {}"?
body: <p>When initializing a dictionary with <code>d = {}</code> Pycharm's code inspector generates a warning, saying</p>
  
  <blockquote>
    <p>This dictionary creation could be rewritten as a dictionary literal.</p>
  </blockquote>
  
  <p>If I rewrite it <code>d = dict()</code> the warning goes away. Since <code>{}</code> already <em>is</em> a dictionary literal, I'm pretty sure the message is erroneous. Furthermore, it seems like both <code>d = {}</code> and <code>d = dict()</code> are valid and Pythonic. </p>
  
  <p>This related question seems to conclude that the choice is just a matter of style/preference:
  <a href="https://stackoverflow.com/questions/2745008/differences-between-d-dict-and-d">differences between &quot;d = dict()&quot; and &quot;d = {}&quot;</a></p>
  
  <p>Why would Pycharm complain about <code>d = {}</code>?</p>
  
  <p><em>UPDATE:</em></p>
  
  <p>Mac nailed it. The warning actually applied to multiple lines, not just the one that was flagged.</p>
  
  <p>Pycharm seems to look for a sequence of consecutive statements where you initialize a dictionary and then set values in the dictionary. For example, this will trigger the warning:</p>
  
  <pre><code>d = {}
  d['a'] = 1
  </code></pre>
  
  <p>But this code will not:</p>
  
  <pre><code>d = {}
  pass
  d['a'] = 1
  </code></pre>