src/eric7/Debugger/VariablesViewer.py

branch
eric7
changeset 11000
f8371a2dd08f
parent 10928
46651e194fbe
child 11006
a671918232f3
diff -r c3cf24fe9113 -r f8371a2dd08f src/eric7/Debugger/VariablesViewer.py
--- a/src/eric7/Debugger/VariablesViewer.py	Tue Oct 22 17:22:53 2024 +0200
+++ b/src/eric7/Debugger/VariablesViewer.py	Tue Oct 22 17:49:41 2024 +0200
@@ -445,15 +445,20 @@
             del parent.children[parent.absolutCount :]
             self.endRemoveRows()
 
-    def resetModifiedMarker(self, parentIdx=QModelIndex(), pathlist=()):
+    def resetModifiedMarker(self, parentIdx=None, pathlist=None):
         """
         Public method to remove the modified marker from changed items.
 
-        @param parentIdx item to reset marker
-        @type QModelIndex
-        @param pathlist full path to the variable
-        @type list of str
+        @param parentIdx item to reset marker (defaults to None)
+        @type QModelIndex (optional)
+        @param pathlist full path to the variable (defaults to None)
+        @type list of str (optional)
         """
+        if parentIdx is None:
+            parentIdx = QModelIndex()
+        if pathlist is None:
+            pathlist = []
+
         parent = parentIdx.internalPointer() if parentIdx.isValid() else self.rootNode
 
         parent.newItems.clear()
@@ -490,27 +495,31 @@
             idxEnd = self.index(0, 2, QModelIndex())
             self.dataChanged.emit(idxStart, idxEnd)
 
-    def columnCount(self, parent=QModelIndex()):  # noqa: U100
+    def columnCount(self, parent=None):  # noqa: U100
         """
         Public method to get the column count.
 
-        @param parent the model parent (unused)
-        @type QModelIndex
+        @param parent the model parent (defaults to None) (unused)
+        @type QModelIndex (optional)
         @return number of columns
         @rtype int
         """
         return 3
 
-    def rowCount(self, parent=QModelIndex()):
+    def rowCount(self, parent=None):
         """
         Public method to get the row count.
 
-        @param parent the model parent
-        @type QModelIndex
+        @param parent the model parent (defaults to None)
+        @type QModelIndex (optional)
         @return number of rows
         @rtype int
         """
-        node = parent.internalPointer() if parent.isValid() else self.rootNode
+        node = (
+            parent.internalPointer()
+            if parent is not None and parent.isValid()
+            else self.rootNode
+        )
 
         return len(node.children)
 
@@ -528,21 +537,21 @@
 
         return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable
 
-    def hasChildren(self, parent=QModelIndex()):
+    def hasChildren(self, parent=None):
         """
         Public method to get a flag if parent has children.
 
-        @param parent the model parent
-        @type QModelIndex
+        @param parent the model parent (defaults to None)
+        @type QModelIndex (optional)
         @return flag indicating parent has children
         @rtype bool
         """
-        if not parent.isValid():
+        if parent is None or not parent.isValid():
             return self.rootNode.children != []
 
         return parent.internalPointer().hasChildren
 
-    def index(self, row, column, parent=QModelIndex()):
+    def index(self, row, column, parent=None):
         """
         Public method to get the index of item at row:column of parent.
 
@@ -550,11 +559,14 @@
         @type int
         @param column number of columns
         @type int
-        @param parent the model parent
-        @type QModelIndex
+        @param parent the model parent (defaults to None)
+        @type QModelIndex (optional)
         @return new model index for child
         @rtype QModelIndex
         """
+        if parent is None:
+            parent = QModelIndex()
+
         if not self.hasIndex(row, column, parent):
             return QModelIndex()
 

eric ide

mercurial