diff --git a/novelwriter/common.py b/novelwriter/common.py index 17fb6403..8ccf0bf0 100644 --- a/novelwriter/common.py +++ b/novelwriter/common.py @@ -30,7 +30,7 @@ import logging import unicodedata import xml.etree.ElementTree as ET -from typing import Any, Literal, TypeGuard +from typing import Any, Literal from pathlib import Path from datetime import datetime from configparser import ConfigParser @@ -134,7 +134,7 @@ def checkPath(value: Any, default: Path) -> Path: # Validator Functions # =============================================================================================== # -def isHandle(value: Any) -> TypeGuard[str]: +def isHandle(value: Any) -> bool: """Check if a string is a valid novelWriter handle. Note: This is case sensitive. Must be lower case! """ @@ -148,7 +148,7 @@ def isHandle(value: Any) -> TypeGuard[str]: return True -def isTitleTag(value: Any) -> TypeGuard[str]: +def isTitleTag(value: Any) -> bool: """Check if a string is a valid title tag string.""" if not isinstance(value, str): return False diff --git a/novelwriter/core/status.py b/novelwriter/core/status.py index ac26641f..203ad6bf 100644 --- a/novelwriter/core/status.py +++ b/novelwriter/core/status.py @@ -27,7 +27,7 @@ from __future__ import annotations import random import logging -from typing import ItemsView, Iterator, KeysView, Literal, TypeGuard, ValuesView +from typing import TYPE_CHECKING, ItemsView, Iterator, KeysView, Literal, ValuesView from PyQt5.QtGui import QIcon, QPainter, QPainterPath, QPixmap, QColor from PyQt5.QtCore import QRectF, Qt @@ -35,6 +35,9 @@ from PyQt5.QtCore import QRectF, Qt from novelwriter import CONFIG from novelwriter.common import minmax, simplified +if TYPE_CHECKING: # pragma: no cover + from typing import TypeGuard # Requires Python 3.10 + logger = logging.getLogger(__name__)