.api/.pyi files and scoped enums
phil at riverbankcomputing.com
Sun Dec 6 10:16:07 GMT 2020
On 06/12/2020 03:55, Kovid Goyal wrote:
> In my opinion, having PyQt6 disallow access to enums at the top level
> is a mistake. FOr the following reasons:
> 1) It adds a huge maintenance burden to move from PyQt5 to
> PyQt6, and Florian's valiant efforts nothwithstanding, this cant be
> automatically. Remember that enum values can be accessed from instances
> as well as classes. For instance the following idiom is very common in
> calibre code:
> d = SomeQDialogDerivedClass()
> if d.exec_() == d.Accepted: # to avoid having to type
> 2) Accessing enum values via scope is a huge and largely unnecessary
> pain. You have to type redundant information every time.
> Qt.GlobalColor.white is just stupid compared to Qt.white. Not to
> that the extra attribute access is a performance cost, albeit a tiny
> I strongly suggest that you preserve the existing top level enums in
> PyQt6. By all means use scoped ones for new enums and change the docs
> encourage people to use scoped ones if you prefer. But breaking
> compatibility like this is really not a good idea. It would be one
> if these could be migrated reliably automatically, but they cant. So
> going to create huge amounts of unneccessary and very boring make work
> and there will be some that inevitably slip through the cracks causing
> runtime errors for end users.
Sorry, not going to happen.
The "new" behaviour was implemented (and the old behaviour deprecated)
in PyQt5 v5.11 (2 and a half years ago). The old behaviour is unPythonic
and inconsistent, the new behaviour uses a standard Python type.
More information about the PyQt