Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion core/schemas/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import unicodedata
from collections.abc import Iterable
from typing import TYPE_CHECKING, ClassVar
from typing import TYPE_CHECKING, Any, ClassVar, Self

from pydantic import BaseModel, computed_field

Expand All @@ -29,6 +29,21 @@ def __init__(self, **data):
def id(self):
return self.__id

if TYPE_CHECKING:
# These are provided at runtime by database_arango.ArangoYetiConnector,
# which every persisted schema type mixes in. They are declared here
# (type-check time only) so type checkers can resolve the calls the
# model mixins below make on `self`. Non-persisted models such as
# YetiTagInstance never call them.
def save(self, *args: Any, **kwargs: Any) -> Self: ...

def delete(self, *args: Any, **kwargs: Any) -> None: ...

def neighbors(self, *args: Any, **kwargs: Any) -> Any: ...

@property
def extended_id(self) -> str: ...


class YetiContextModel(YetiBaseModel):
context: list[dict] = []
Expand Down Expand Up @@ -254,6 +269,8 @@ def tag(
if clear:
for tag_name in removed_tags:
removed_tag = tag.Tag.find(name=tag_name)
if not removed_tag:
continue
removed_tag.count -= 1
removed_tag.save()

Expand Down Expand Up @@ -300,6 +317,8 @@ def clear_tags(self):

for obj_tag in self.tags:
db_tag = tag.Tag.find(name=obj_tag.name)
if not db_tag:
continue
db_tag.count -= 1
db_tag.save()
self.tags = []
Expand Down
Loading