[PyQt] PyQt/PyCharm/PEP problem with PyQt types

Florian Bruhin me at the-compiler.org
Wed Nov 22 10:29:52 GMT 2017


On Wed, Nov 22, 2017 at 10:18:16AM +0000, Phil Thompson wrote:
> On 22 Nov 2017, at 10:13 am, J Barchan <jnbarchan at gmail.com> wrote:
> > 
> > @Florian & @Phil,
> > 
> > Your posts crossed with my last one above.
> > 
> > Technically as I wrote there, one does not have to "go through Qt reading whether a "QObject *" does or does not accept NULL/None, because it automatically does.  As I wrote, if it does not, the correct Qt C++ declaration would have been "QObject &", and that was up to the Qt people, not PyQt to guess.
> > 
> > Having said that, I realise we are where we are.  (Unless PyQt wants to change the declarations at the next release.)  I am concerned about what I can do moving on.  You guys have clarified to me that I am not "missing something" which would have solved this neatly.  I now can declare my own function parameters/returns with Union; I am stuck with where a PyQt function does not do so and so I will get a warning on my calling code, but at least I know where I am.  So thank you all.
> 
> I'm happy to change things so they work better. I don't use them myself so other people need to come to a consensus about any changes. When I added support I tried to get the PyCharm people to comment and/or verify the decisions I took but they were completely unresponsive.
> 
> Phil

IIRC the reason you didn't want to do mypy related changes for other issues[1]
is because they'd make autocompletion in IDEs work worse with the annotations,
which is probably a good reason.

Here I don't really see downsides to using Optional[T] for everywhere C++ has
a *T, as long as autocompletion in e.g. PyCharm will still work (I'd expect it to).

This means some mistakes can't be prevented, but that's because the PyQt/Qt
typesystem can't prevent them - so I think that'd be fine.

Florian

[1] https://github.com/python/mypy/issues/1237

-- 
https://www.qutebrowser.org  | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072  | https://the-compiler.org/pubkey.asc
         I love long mails!  | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20171122/df6f7837/attachment.sig>


More information about the PyQt mailing list