python-qt-tools / PySide6-stubs

Stubs for Qt6 for Python/PySide6
GNU Lesser General Public License v2.1
16 stars 4 forks source link

Missing types for Public Variables #3

Open boldar99 opened 1 year ago

boldar99 commented 1 year ago

The variables that correspond to Public Variables of the C++ implementation don't have type annotations.

One example would be the QStyleOption class: The C++ doc: https://doc.qt.io/qt-6/qstyleoption.html#public-variables The PySides6 doc: https://doc.qt.io/qtforpython-6/PySide6/QtWidgets/QStyleOption.html#PySide6.QtWidgets.PySide6.QtWidgets.QStyleOption.version Stubs: https://github.com/python-qt-tools/PySide6-stubs/blob/main/PySide6-stubs/QtWidgets.pyi#L7038-L7086

But other classes seem to miss these variables as well, e.g., QStyleHintReturnVariant, PixmapFragment.

bluebird75 commented 1 year ago

Indeed.

One would have to experiment to see if we can detect which variables are public variables, and what their type is. Then amend the stubs with this information.

I am not sure that it is feasible, it might be just easier to report that to Qt and wait looooooooooooooong for their fix.

boldar99 commented 1 year ago

Thanks for the response! I have submitted an issue to Qt: https://bugreports.qt.io/browse/PYSIDE-2452. Hopefully, they'll fix it soon!

bluebird75 commented 1 year ago

I tried with #5 . I can identify public variable, I can identify some limited type information. Unfortunately, I can not get a fully qualified type name. I can identify a type as "QRect" or "StateFlag". But this is not sufficient for annotating the variables. Especially since some subclasses in Qt can have the same name in multiple different classes.

So, parsing the stubs is not going to solve this problem.

I have no other ideas at the moment...