Skip to content

Commit

Permalink
Making rewrite_action.py well-typed
Browse files Browse the repository at this point in the history
  • Loading branch information
boldar99 committed Jul 5, 2024
1 parent 16f6d10 commit 0e8fcc9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions zxlive/rewrite_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import copy
from dataclasses import dataclass, field
from typing import Callable, TYPE_CHECKING, Any, Optional, cast, Union
from typing import Callable, TYPE_CHECKING, Any, cast, Union

import pyzx
from PySide6.QtCore import Qt, QAbstractItemModel, QModelIndex, QPersistentModelIndex, Signal, QObject, QMetaObject
Expand Down Expand Up @@ -176,16 +176,17 @@ def index(self, row: int, column: int, parent: Union[QModelIndex, QPersistentMod
return self.createIndex(row, column, childItem)
return QModelIndex()

def parent(self, index: QModelIndex | QPersistentModelIndex = QModelIndex()) -> QModelIndex:
def parent(self, index: QModelIndex | QPersistentModelIndex = QModelIndex()) -> QModelIndex: # type: ignore[override]
if not index.isValid():
return QModelIndex()

parent_item = cast(RewriteActionTree, index.internalPointer()).parent
row = parent_item is None or parent_item.row()

if parent_item == self.root_item:
if row is None or parent_item == self.root_item:
return QModelIndex()

return self.createIndex(parent_item.row(), 0, parent_item)
return self.createIndex(row, 0, parent_item)

def rowCount(self, parent: QModelIndex | QPersistentModelIndex = QModelIndex()) -> int:
if parent.column() > 0:
Expand Down

0 comments on commit 0e8fcc9

Please sign in to comment.