Details
Description
The following subclasses are missing when importing QtCore, QtGui, and QtWidgets and then importing * from them:
- QAbstractEventDispatcher.TimerInfo
- QAbstractTextDocumentLayout.PaintContext
- QAbstractTextDocumentLayout.Selection
- QAccessible.State
- QByteArray.FromBase64Result
- QCalendar.SystemId
- QCalendar.YearMonthDay
- QDirListing.DirEntry
- QFormLayout.TakeRowResult
- QPageRanges.Range
- QPainter.PixmapFragment
- QPainterPath.Element
- QProcess.UnixProcessParameters
- QRhiTexture.ViewFormat
- QTextEdit.ExtraSelection
- QTextLayout.FormatRange
The following code demonstrates a different behavior when importing a Qt module and not:
IMPORT_MODULES = False _init = set(globals()) if IMPORT_MODULES: from PySide6 import QtCore from PySide6 import QtGui from PySide6 import QtWidgets from PySide6.QtCore import * from PySide6.QtGui import * from PySide6.QtWidgets import * _imported = set(globals()) - _init def subclasses(): import enum for class_name in _imported: if class_name[1].isupper() and isinstance((cls:=globals()[class_name]), type): for subclass_name in cls.__dict__: if subclass_name[0].isupper(): if isinstance((subclass:=getattr(cls, subclass_name)), type) and enum.Enum not in subclass.__mro__: yield class_name, subclass_name print(sum(1 for _ in subclasses()), "subclasses found") print(*sorted(map('.'.join, subclasses())), sep='\n')
With IMPORT_MODULES set to False, it finds 30 non-Enum subclasses, whereas with True, only 14.
The same behavior takes place when instead of from PySide6 import <module> one does from PySide6.<module> import <something>.
Attachments
Issue Links
- is duplicated by
-
PYSIDE-2896 'PySide6.QtGui.QTextLayout' has no attribute 'FormatRange'
- Closed