-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use PySide6 #9586
base: main
Are you sure you want to change the base?
Use PySide6 #9586
Conversation
be4a6dc
to
c7090c4
Compare
CodSpeed Performance ReportMerging #9586 will not alter performanceComparing Summary
|
429fc1e
to
a397c37
Compare
It fails locally on MacOS with python3.12, but I got it working by modifying:
|
When it failed it emitted:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9586 +/- ##
==========================================
- Coverage 91.86% 91.84% -0.02%
==========================================
Files 433 433
Lines 26775 26798 +23
==========================================
+ Hits 24596 24613 +17
- Misses 2179 2185 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Thank you for the help :) |
Upgrade from qtpy with pyqt5 to PySide6. Using PySide6 directly should give us better typing.
def keyPressEvent(self, arg__1: QKeyEvent) -> None: | ||
if arg__1 is not None and arg__1.key() == Qt.Key.Key_Escape: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we checking if it is not None, if the parameter cannot be None?
def parent(self, child: QModelIndex | None = None) -> QObject | None: | ||
def parent( | ||
self, child: QModelIndex | QPersistentModelIndex | None = None | ||
) -> QObject | QModelIndex: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need QObject
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have no choice. we are overriding existing methods.
https://doc.qt.io/qtforpython-6/PySide6/QtCore/QObject.html#PySide6.QtCore.QObject.parent
https://doc.qt.io/qtforpython-6/PySide6/QtCore/QAbstractItemModel.html#PySide6.QtCore.QAbstractItemModel.parent
if parent is None: | ||
parent = QModelIndex() | ||
parent_item = self.root if not parent.isValid() else parent.internalPointer() | ||
|
||
if parent.column() > 0: | ||
return 0 | ||
|
||
return len(parent_item.children) | ||
return len(parent_item.children) # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need type: ignore
?
def parent(self, child: QModelIndex | None = None) -> QObject | None: | ||
def parent( | ||
self, child: QModelIndex | QPersistentModelIndex | None = None | ||
) -> QObject | QModelIndex: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also need QObject?
For QModelIndex, is it possible to have the typing include specifically what the index is pointing to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both of the parent overloads come from inherited methods. the override must handle them both
if child is None or not child.isValid(): | ||
return QModelIndex() | ||
|
||
parent_item = child.internalPointer().parent | ||
parent_item = child.internalPointer().parent # type:ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another type:ignore. Maybe we dont need it?
self, | ||
index: QModelIndex | QPersistentModelIndex, | ||
role: int = Qt.ItemDataRole.DisplayRole, | ||
) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use Any?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an override. It comes from QAbstractItemModel
def _real_data(_: QModelIndex, node: RealNode, role: int) -> Any: | ||
def _real_data( | ||
_: QModelIndex | QPersistentModelIndex, node: RealNode, role: int | ||
) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another Any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is only used by the data() method which returns any
@@ -445,7 +464,7 @@ def _fm_step_data( | |||
if role == FileRole: | |||
data_name = FM_STEP_COLUMNS[index.column()] | |||
if data_name in {ids.STDOUT, ids.STDERR}: | |||
return node.data.get(data_name, QVariant()) | |||
return node.data.get(data_name, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is None
redundant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ids.STDOUT and ids.STDERR are both optional in the typeddict. we need the None if they are not defined
@@ -307,17 +306,18 @@ def on_snapshot_new_iteration( | |||
) -> None: | |||
if not parent.isValid(): | |||
index = self._snapshot_model.index(start, 0, parent) | |||
iteration = cast(Node, index.internalPointer()).id_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we cast it to Node or IterationNode? I think the point of having Node prefixed with underscore was that it would not be imported elsewhere
) | ||
|
||
from ert.ensemble_evaluator.state import ENSEMBLE_STATE_FAILED, REAL_STATE_TO_COLOR | ||
|
||
|
||
class ProgressWidget(QFrame): | ||
def __init__(self) -> None: | ||
QWidget.__init__(self) | ||
QFrame.__init__(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change this to super().__init__()
?
@@ -110,5 +109,5 @@ def update_progress(self, status: dict[str, int], realization_count: int) -> Non | |||
self.stop_waiting_progress_bar() | |||
self.repaint_components() | |||
|
|||
def resizeEvent(self, a0: Any, event: Any = None) -> None: | |||
def resizeEvent(self, event: Any = None) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more specific event type we can use?
@@ -127,7 +127,7 @@ def iteration(self) -> int: | |||
def _insert_status_message(self, message: str) -> None: | |||
item = QListWidgetItem() | |||
item.setText(message) | |||
item.setFlags(item.flags() & ~Qt.ItemFlags(Qt.ItemFlag.ItemIsEnabled)) | |||
item.setFlags(item.flags() & ~Qt.ItemFlag.ItemIsEnabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use item.setFlag
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no setFlag method on QListWidgetItem
@@ -131,6 +134,7 @@ def __init__( | |||
self.setStyleSheet(f"background-color: {LIGHT_GREY}; color: black") | |||
self.__layout.setContentsMargins(32, 47, 32, 16) | |||
self.__layout.setSpacing(32) | |||
self.notifier = notifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need access to the notifier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good! I have some questions, see comments :)
Upgrade from qtpy with pyqt5 to PySide6.
Using PySide6 directly should give us better typing.
git rebase -i main --exec 'pytest tests/ert/unit_tests -n logical -m "not integration_test"'
)When applicable