Skip to content

Commit

Permalink
Suppress mismatched signature errors in type-checking.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gycsaba96 authored and diegogangl committed Sep 23, 2024
1 parent 3182d26 commit 17781fc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions GTG/core/base_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion GTG/core/saved_searches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion GTG/core/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]
Expand Down
4 changes: 2 additions & 2 deletions GTG/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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))
Expand Down

0 comments on commit 17781fc

Please sign in to comment.