Simplify _misplaced_members dict
I noticed a lot of duplication of the key in the value in _misplaced_members. This adds extra lines to Qt.py that are not required for it to run. Do we want to keep this duplication as some sort of documentation? If so, we should probably add a comment stating that.
$ git diff -U4 Qt.py
diff --git a/Qt.py b/Qt.py
index f867f25..cf822c3 100644
--- a/Qt.py
+++ b/Qt.py
@@ -685,37 +685,20 @@ These members from the original submodule are misplaced relative PySide2
"""
_misplaced_members = {
"PySide2": {
"QtGui.QStringListModel": "QtCore.QStringListModel",
- "QtCore.Property": "QtCore.Property",
- "QtCore.Signal": "QtCore.Signal",
- "QtCore.Slot": "QtCore.Slot",
- "QtCore.QAbstractProxyModel": "QtCore.QAbstractProxyModel",
- "QtCore.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel",
- "QtCore.QItemSelection": "QtCore.QItemSelection",
- "QtCore.QItemSelectionModel": "QtCore.QItemSelectionModel",
- "QtCore.QItemSelectionRange": "QtCore.QItemSelectionRange",
},
"PyQt5": {
"QtCore.pyqtProperty": "QtCore.Property",
"QtCore.pyqtSignal": "QtCore.Signal",
"QtCore.pyqtSlot": "QtCore.Slot",
- "QtCore.QAbstractProxyModel": "QtCore.QAbstractProxyModel",
- "QtCore.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel",
- "QtCore.QStringListModel": "QtCore.QStringListModel",
- "QtCore.QItemSelection": "QtCore.QItemSelection",
- "QtCore.QItemSelectionModel": "QtCore.QItemSelectionModel",
- "QtCore.QItemSelectionRange": "QtCore.QItemSelectionRange",
},
"PySide": {
"QtGui.QAbstractProxyModel": "QtCore.QAbstractProxyModel",
"QtGui.QSortFilterProxyModel": "QtCore.QSortFilterProxyModel",
"QtGui.QStringListModel": "QtCore.QStringListModel",
"QtGui.QItemSelection": "QtCore.QItemSelection",
"QtGui.QItemSelectionModel": "QtCore.QItemSelectionModel",
- "QtCore.Property": "QtCore.Property",
- "QtCore.Signal": "QtCore.Signal",
- "QtCore.Slot": "QtCore.Slot",
"QtGui.QItemSelectionRange": "QtCore.QItemSelectionRange",
"QtGui.QAbstractPrintDialog": "QtPrintSupport.QAbstractPrintDialog",
"QtGui.QPageSetupDialog": "QtPrintSupport.QPageSetupDialog",
"QtGui.QPrintDialog": "QtPrintSupport.QPrintDialog",
Just removing the existing duplicates removes 17 lines. If we want to keep the duplication we will need to add an additional 16 lines to add the duplicate QtPrintsupport to PyQt5 and PySide2.
Personally I like it being there as a sort of documentation.
If we get to a point where it gets quite large and there are performance or memory implications then I would be for removing it.
Basically I think it's slightly beneficial, enough to not want to remove, but not enough to trade off for performance.
Just my thoughts
Do these not need to be there? Would they not be excluded from Qt.py is they got removed? I remember thinking about this duplication at some point, and that there was a reason for having it.. but if they really aren't technically needed, then my vote is for removing them.
We wouldn't/shouldn't need a section for PySide2, as these are members missing from PySide2. PySide2 would not be missing any, because, you know it's PySide2. :)
Unless I'm missing something, I don't think they are technically needed because the duplication is in the key, value per binding. ie, we are trying to map the source to the destination when its already mapped. Yeah, PySide2 should be empty, I'm not sure what the story with QStringListModel is as listed above, but we may need to keep that one for backwards compatibility.
Removing the duplicates is a minor optimization because it means there is less to loop over and check, but I assume it doesn't take long to do that loop as its all dictionary lookup.
Ok, I had a closer look and remembered why they are there.
It's because they aren't in the main _common_members list of members. Such as Signal. If we don't add it here, it won't get included at all. And we can't add it to the main list, because it doesn't exist in each of them (PyQt5 has pyqtSignal for example).
It's still a little confusing though, and the fact that this issue exist is testament to that I think. So if there are any suggestions for doing things differently, I'm all ears.
That makes sense, I was thinking of it from the perspective of QtPrintSupport. Everything in that is a common member with the same name, just located under different modules. It's included in _common_members by membership.py so there is no need to include it in the PySide2 and PyQt5 _misplaced_members.
I think we could:
- Update the _misplaced_members documentation to be more clear. Why some key,value duplication is needed(Signal), and why its not always needed(QtPrintSupport), etc. Remove duplication for anything included in _common_members.
- Update membership.py to consider Signal/pyqtSignal, etc as common and include Signal in _common_members.
- Always include duplicate key value pairs, add tests to make sure they are always there and document it.
It also would be nice to have a breakdown of what each part of the _missplaced_members dictionary is used for, I always have to guess where to stick the key and where to stick the value.
My vote is for the first one.
My vote is for the first one.
👍