From 08648e0a336d83669c540876d8a5f445166483ce Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Fri, 28 Jul 2023 23:17:09 +0200 Subject: [PATCH] Update annotations in related source --- novelwriter/core/item.py | 12 ++++++++++-- novelwriter/core/tree.py | 8 ++++---- novelwriter/gui/doceditor.py | 2 +- novelwriter/gui/itemdetails.py | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/novelwriter/core/item.py b/novelwriter/core/item.py index 943e7c7b..51f9f5b7 100644 --- a/novelwriter/core/item.py +++ b/novelwriter/core/item.py @@ -25,7 +25,7 @@ from __future__ import annotations import logging -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any, Literal, overload from PyQt5.QtGui import QIcon @@ -308,7 +308,15 @@ class NWItem: return trConst(nwLabels.ITEM_DESCRIPTION.get(descKey, "")) - def getImportStatus(self, incIcon: bool = True) -> tuple[str, QIcon | None]: + @overload # pragma: no cover + def getImportStatus(self, incIcon: Literal[True] = True) -> tuple[str, QIcon]: + pass + + @overload # pragma: no cover + def getImportStatus(self, incIcon: Literal[False]) -> tuple[str, None]: + pass + + def getImportStatus(self, incIcon=True): """Return the relevant importance or status label and icon for the current item based on its class. """ diff --git a/novelwriter/core/tree.py b/novelwriter/core/tree.py index 7da3e6ac..31969a9d 100644 --- a/novelwriter/core/tree.py +++ b/novelwriter/core/tree.py @@ -93,14 +93,14 @@ class NWTree: """Returns a copy of the list of all the active handles.""" return self._treeOrder.copy() - @overload + @overload # pragma: no cover def create(self, label: str, parent: None, itemType: Literal[nwItemType.ROOT], - itemClass: nwItemClass) -> str: # pragma: no cover + itemClass: nwItemClass) -> str: pass - @overload + @overload # pragma: no cover def create(self, label: str, parent: str | None, itemType: nwItemType, - itemClass: nwItemClass = nwItemClass.NO_CLASS) -> str | None: # pragma: no cover + itemClass: nwItemClass = nwItemClass.NO_CLASS) -> str | None: pass def create(self, label, parent, itemType, itemClass=nwItemClass.NO_CLASS): diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index a86b15c7..b30357d2 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -3034,7 +3034,7 @@ class GuiDocEditFooter(QWidget): sIcon = QPixmap() sText = "" else: - theStatus, theIcon = self._theItem.getImportStatus() + theStatus, theIcon = self._theItem.getImportStatus(incIcon=True) sIcon = theIcon.pixmap(self.sPx, self.sPx) sText = f"{theStatus} / {self._theItem.describeMe()}" diff --git a/novelwriter/gui/itemdetails.py b/novelwriter/gui/itemdetails.py index be0cf144..163e0d4d 100644 --- a/novelwriter/gui/itemdetails.py +++ b/novelwriter/gui/itemdetails.py @@ -263,7 +263,7 @@ class GuiItemDetails(QWidget): # Status # ====== - theStatus, theIcon = nwItem.getImportStatus() + theStatus, theIcon = nwItem.getImportStatus(incIcon=True) self.statusIcon.setPixmap(theIcon.pixmap(iPx, iPx)) self.statusData.setText(theStatus)