PyQt Type hinting
已回答
Let me first say I love PyCharm, and your support for open source.
I'm just a bit stuck on type hinting with PyQt. Take a look at the image below, when I type "b." I would expect it to list the methods of QPixmap, instead it lists the QPixmap class and its super class. Pressing enter just inserts QPixmap. Surely I must be doing something wrong?

请先登录再写评论。
Hi Philip! Looks like a bug. I created a corresponding ticket in our bug tracker: PY-26329.
Thankyou Pavel
Far be it for me, but although Pavel knows much better than I do I'm not sure where the bug is, or at least read on.
I got your behaviour with `:rtype: PyQt5.QtGui.QPixmap`. However, with:
```
from PyQt5 import QtGui
```
I get correct completions offered!
Also if I use:
```
from PyQt5 import QtGui
```
completions work, which is how I do type annotations.
There seems to be something about need the `import PyQt5` statement to keep PyCharm happy here. Also in the `:rtype:` statement PyCharm squiggles just the `Pixmap` part of the word, which is wrong (but not in the ` -> ` type declaration).
```
from PyQt5 import QtGui
```
is ok, but if you're not using QtGui in the module (except for documentation) the import seems superfluous.
def a() -> PyQt5.QtGui.QPixmap:
would be my preferred way, but the project lead doesn't like it, so unfortunately my hands are tied!
@Philip Ridout
For me `def a() -> PyQt5.QtGui.QPixmap:` does not work. I *have to* do an `from PyQt5 import QtGui` statement and then use `-> QtGui.QPixmap`. Might be something to do with my code, dunno.
" [ -> ] but the project lead doesn't like it" What project lead? In PyQt5 (at least) all the `pyi` files I see use that style anyway....
Sorry, by 'The project lead' I mean the person who is managing the project.
Which project??!! PyQt or PyCharm?
The open source project I contribute. OpenLP.org
OIC! I misunderstood, I get it now. It's your team leader who's imposing the rules.
Well, as I said above I found a way which gives you the right completions for either `:rtype:` or `->` type annotations, without waiting for "bug fix".
And BTW, a superfluous `import PyQt5....` shouldn't make that much difference, given that your project is using PyQt elsewhere and imports are cached. Up to you if you want it to work now :)