From be6888f8c855beb187b4a92ac630342a2fb0fd5d Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 23 Nov 2024 20:29:02 +0100 Subject: [PATCH] Fix Python 3.9 incompatible type --- novelwriter/core/itemmodel.py | 4 +++- novelwriter/core/project.py | 6 +++++- novelwriter/core/status.py | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/novelwriter/core/itemmodel.py b/novelwriter/core/itemmodel.py index 948b6146e..8042a3f22 100644 --- a/novelwriter/core/itemmodel.py +++ b/novelwriter/core/itemmodel.py @@ -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: diff --git a/novelwriter/core/project.py b/novelwriter/core/project.py index 31a449193..4e16dd53b 100644 --- a/novelwriter/core/project.py +++ b/novelwriter/core/project.py @@ -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 @@ -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__) diff --git a/novelwriter/core/status.py b/novelwriter/core/status.py index 358f9ced9..fa3a3dfc1 100644 --- a/novelwriter/core/status.py +++ b/novelwriter/core/status.py @@ -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: