Skip to content

Commit

Permalink
Fix Python 3.9 incompatible type
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Nov 23, 2024
1 parent c1ed064 commit be6888f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion novelwriter/core/itemmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
NODE_FLAGS |= Qt.ItemFlag.ItemIsSelectable
NODE_FLAGS |= Qt.ItemFlag.ItemIsDropEnabled

T_NodeData = str | QIcon | QFont | Qt.AlignmentFlag | None
if TYPE_CHECKING: # pragma: no cover
# Requires Python 3.10
T_NodeData = str | QIcon | QFont | Qt.AlignmentFlag | None


class ProjectNode:
Expand Down
6 changes: 5 additions & 1 deletion novelwriter/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from functools import partial
from pathlib import Path
from time import time
from typing import TYPE_CHECKING

from PyQt5.QtCore import QCoreApplication

Expand All @@ -44,12 +45,15 @@
from novelwriter.core.projectdata import NWProjectData
from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState
from novelwriter.core.sessions import NWSessionLog
from novelwriter.core.status import T_StatusKind, T_UpdateEntry
from novelwriter.core.storage import NWStorage, NWStorageOpen
from novelwriter.core.tree import NWTree
from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType
from novelwriter.error import logException

if TYPE_CHECKING: # pragma: no cover
# Requires Python 3.10
from novelwriter.core.status import T_StatusKind, T_UpdateEntry

logger = logging.getLogger(__name__)


Expand Down
6 changes: 4 additions & 2 deletions novelwriter/core/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ def duplicate(cls, source: StatusEntry) -> StatusEntry:

NO_ENTRY = StatusEntry("", QColor(0, 0, 0), nwStatusShape.SQUARE, QIcon(), 0)

T_UpdateEntry = list[tuple[str | None, StatusEntry]]
T_StatusKind = Literal["s", "i"]
if TYPE_CHECKING: # pragma: no cover
# Requires Python 3.10
T_UpdateEntry = list[tuple[str | None, StatusEntry]]
T_StatusKind = Literal["s", "i"]


class NWStatus:
Expand Down

0 comments on commit be6888f

Please sign in to comment.