V0.4 - PyCharm "unknown" inspections: `unexpected argument`, `not callable`, etc

mattrobin: <p>After installing PyTorch via pip on Mac, my PyCharm seems to not be recognizing many of the v0.4 commands. For example, for <code>torch.rand</code> the <code>device</code> argument is an <code>unexpected argument</code>, and <code>torch.tensor</code> is considered <code>not callable</code>. Of course, it’s possible to disable these inspections, but I would prefer the inspections remained on if possible. The correct interpreter seems to be being used, so I think it’s due to how the PyTorch code is written that’s causing PyCharm not to recognize this commands in the right way. Is there an existing solution to this issue? Or perhaps am I mistaken with my setup and all the commands should be correctly recognized? Thank you for your time!</p>

colesbury: <p>We will fix this in the next release. It’s being tracked at:</p>
<aside class="onebox githubissue">
  <header class="source">
      <a href="https://github.com/pytorch/pytorch/issues/7318" target="_blank">github.com/pytorch/pytorch</a>
  </header>
  <article class="onebox-body">
    <a href="https://github.com/kimdwkimdw">
<img src="https://avatars1.githubusercontent.com/u/386070?v=2&amp;s=96" class="thumbnail onebox-avatar" width="60" height="60">
</a>

<h4><a href="https://github.com/pytorch/pytorch/issues/7318" target="_blank">Issue: Broken `Type Hints` in PyTorch 0.4.0, related to IDEs(eq. PyCharm)</a></h4>

<div class="date" style="margin-top:10px;">
	<div class="user" style="margin-top:10px;">
	opened by <a href="https://github.com/kimdwkimdw" target="_blank">kimdwkimdw</a>
	on <a href="https://github.com/pytorch/pytorch/issues/7318" target="_blank">2018-05-05</a>
	</div>
	<div class="user">
	</div>
</div>

<pre class="content" style="white-space: pre-wrap;">If you have a question or would like help and support, please ask at our
forums.
If you are submitting a feature request,...</pre>

<div class="labels">
</div>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>


mattrobin: <p>Good to hear a fix is being discussed. This does however reveal another concerning issue: the PyTorch developers don’t use the JetBrains IDEs. That alone may be enough to drive me back to TensorFlow.</p>
<p>(I’m just kidding. I could never do such a thing.)</p>

11177: <p>I am using pycharm professional connected a remote linux server. powerful!</p>

harpone: <p>Haha! <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=5" title=":slight_smile:" class="emoji" alt=":slight_smile:"> But IMO you do have a point. PyCharm debugger is just awesome and I’m just relying on it more and more in my day to day workflow.</p>
<p>Here’s an example: I’m starting to write some code from scratch. I’m not sure if I got the shapes/outputs right so I just set a breakpoint at a line and run the debugger. Execution stops at the line and now I can either hit Alt+F8 to evaluate expression or open a console and print stuff or plot activations as much as I want. I can also continue writing the code in the expression evaluator to check it works right and copypaste that to the actual code etc. Makes development just that much faster! Still, if others have even more efficient working habits, I’m all ears! <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=5" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

mattrobin: <p>I have a very temporary solution until a real fix is available. This is for those who are very hesitant to disable inspections, but who can’t stand the warnings being listed in PyCharm.</p>
<p>In one of your files in PyCharm, type in <code>torch.abs()</code>. Right click on <code>abs</code>, and select <code>Go To -&gt; Declaration</code>. This will drop you into PyCharm’s auto generated python stubs for PyTorch. For any of the functions that are giving you a warning, just copy an existing function stub, and give it the proper signature for the missing function (don’t worry about the example or description). Your manually added pieces will certainly be overwritten when you make a change to the interpreter that results in re-caching, but it’ll allow you to get rid of the warnings for now at least (and fix some autocomplete, etc).</p>

amirkhas: <p>Hi,</p>
<p>It is still an unsolved issue, right?<br>
With latest updates of both pycharm and pytorch …<br>
So when does PyTorch is going to release that ideal version?</p>
<p>Thanks</p>

amirkhas: <p>Thank you for the reply but I have seen this github issue before and I don’t see any progress in it.<br>
Please let me know if a PyTorch release is not going to solve the problem in the very near future, I don’t waste time and switch back to TF ASAP or don’t use pycharm for the project.</p>
<p>Thank you very much</p>

mattrobin: <p>You’re right. They’ve bumped up the priority on it, but it doesn’t look like any of the main developers directly are working on it. So it’ll probably take a while. And I’m not sure what to tell you between switching back to TF or not using PyCharm. PyCharm is good enough to make that a hard choice.</p>

sanyam5: <p>Any progress on this?</p>

sami: <p>I’d also be interested on the progress on this! <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=6" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

sanyam5: <p>I think the latest pytorch 1.0.1 or later version has it fixed.</p>