From 152722db5d25ffee7cc32b79c4886557fcfd4982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csaba=20Gy=C3=B6rgyi?= Date: Sun, 22 Sep 2024 13:29:12 +0200 Subject: [PATCH] Suppress mismatched signature errors in type-checking. The only purpose of the BaseStore.new and BaseStore.from_xml methods is to provide an overview of how to use the subclasses. However, the mismatched signatures caused typing errors. Suppressing these errors instead of simply deleting the base class methods can still provide this "educational" benefit. --- GTG/core/base_store.py | 6 ++++++ GTG/core/saved_searches.py | 2 +- GTG/core/tags.py | 2 +- GTG/core/tasks.py | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/GTG/core/base_store.py b/GTG/core/base_store.py index e4c070de1..2aa12d85f 100644 --- a/GTG/core/base_store.py +++ b/GTG/core/base_store.py @@ -53,6 +53,9 @@ def __init__(self) -> None: # -------------------------------------------------------------------------- def new(self) -> S: + """Creates a new item in the store. + NOTE: Subclasses may override the signature of this method. + """ raise NotImplementedError @@ -177,6 +180,9 @@ def unparent(self, item_id: UUID, parent_id: UUID) -> None: # -------------------------------------------------------------------------- def from_xml(self, xml: _Element) -> None: + """Load data from XML. + NOTE: Subclasses may override the signature of this method. + """ raise NotImplementedError diff --git a/GTG/core/saved_searches.py b/GTG/core/saved_searches.py index 7a6426f91..4e9a6c610 100644 --- a/GTG/core/saved_searches.py +++ b/GTG/core/saved_searches.py @@ -162,7 +162,7 @@ def to_xml(self) -> _Element: return root - def new(self, name: str, query: str, parent: Optional[UUID] = None) -> SavedSearch: + def new(self, name: str, query: str, parent: Optional[UUID] = None) -> SavedSearch: # type: ignore[override] """Create a new saved search and add it to the store.""" search_id = uuid4() diff --git a/GTG/core/tags.py b/GTG/core/tags.py index 4f3877243..8eabf1e91 100644 --- a/GTG/core/tags.py +++ b/GTG/core/tags.py @@ -245,7 +245,7 @@ def find(self, name: str) -> Tag: return self.lookup_names[name] - def new(self, name: str, parent: Optional[UUID] = None) -> Tag: + def new(self, name: str, parent: Optional[UUID] = None) -> Tag: # type: ignore[override] """Create a new tag and add it to the store.""" name = name if not name.startswith('@') else name[1:] diff --git a/GTG/core/tasks.py b/GTG/core/tasks.py index 1167bbca1..9150ae6a1 100644 --- a/GTG/core/tasks.py +++ b/GTG/core/tasks.py @@ -766,7 +766,7 @@ def duplicate_for_recurrent(self, task: Task) -> Task: return new_task - def new(self, title: str = '', parent: Optional[UUID] = None) -> Task: + def new(self, title: str = '', parent: Optional[UUID] = None) -> Task: # type: ignore[override] """Create a new task and add it to the store.""" tid = uuid4() @@ -784,7 +784,7 @@ def new(self, title: str = '', parent: Optional[UUID] = None) -> Task: return task - def from_xml(self, xml: _Element, tag_store: TagStore) -> None: + def from_xml(self, xml: _Element, tag_store: TagStore) -> None: # type: ignore[override] """Load up tasks from a lxml object.""" elements = list(xml.iter(self.XML_TAG))