Details
Description
If you subclass a Qt class, for example QObject, the __doc__ returns None, that doesn't happen if the instance is used. The sphinx uses FooClass.__doc__ to access the class documentation so in general the documentation is problematic.
from PyQt6.QtCore import QObject as PyQt6QObject from PySide6.QtCore import QObject as PySide6QObject class Foo: """Foo docs""" class PyQt6Foo(PyQt6QObject): """PyQt6Foo docs""" class PySide6Foo(PySide6QObject): """PySide6Foo docs""" print("* From class:") print("Foo:", Foo.__doc__) print("PyQt6QObject:", PyQt6QObject.__doc__) print("PySide6QObject:", PySide6QObject.__doc__) print("PyQt6Foo:", PyQt6Foo.__doc__) print("PySide6Foo:", PySide6Foo.__doc__) print("* From instance:") print("Foo:", Foo().__doc__) print("PyQt6Foo:", PyQt6Foo().__doc__) print("PySide6Foo:", PySide6Foo().__doc__)
Output:
* From class: Foo: Foo docs PyQt6QObject: QObject(parent: QObject = None) PySide6QObject: QObject(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None PyQt6Foo: PyQt6Foo docs PySide6Foo: None * From instance: Foo: Foo docs PyQt6Foo: PyQt6Foo docs PySide6Foo: PySide6Foo docs
Attachments
Issue Links
- is duplicated by
-
PYSIDE-2131 Docstrings not preserved in subclasses of QObject
- Closed
- relates to
-
PYSIDE-1084 Segfault when accessing __doc__ for several QtCore members (during pylint)
- Closed