diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py index d8e6a367077b104d8b1ed5f3631dec470eaf8381..ba42b972856205cd73f9e1e654edbb6f0b09efbc 100644 --- a/src/linkahead/common/models.py +++ b/src/linkahead/common/models.py @@ -4874,7 +4874,7 @@ def execute_query( cache: bool = True, flags: Optional[QueryDict] = None, page_length: Optional[int] = None, -) -> Union[Container, int]: +) -> Union[Container, Entity, int]: """Execute a query (via a server-requests) and return the results. Parameters @@ -4913,7 +4913,7 @@ def execute_query( Returns ------- - results : Container or integer + results : Container or Entity or integer Returns an integer when it was a `COUNT` query. Otherwise, returns a Container with the resulting entities. """ diff --git a/src/linkahead/utils/get_entity.py b/src/linkahead/utils/get_entity.py index 282f7c86e10571d0e0d62b93da7f61bba5205cba..ce74089784525b1a38d9c5c5bbf3193a9ba94575 100644 --- a/src/linkahead/utils/get_entity.py +++ b/src/linkahead/utils/get_entity.py @@ -33,7 +33,8 @@ def get_entity_by_name(name: str) -> Entity: Submits the query "FIND ENTITY WITH name='{name}'". """ name = escape_squoted_text(name) - return execute_query(f"FIND ENTITY WITH name='{name}'", unique=True) + # type hint can be ignored, it's a unique query, so never Container or int + return execute_query(f"FIND ENTITY WITH name='{name}'", unique=True) # type: ignore def get_entity_by_id(eid: Union[str, int]) -> Entity: @@ -41,7 +42,8 @@ def get_entity_by_id(eid: Union[str, int]) -> Entity: Submits the query "FIND ENTITY WITH id='{eid}'". """ - return execute_query(f"FIND ENTITY WITH id='{eid}'", unique=True) + # type hint can be ignored, it's a unique query + return execute_query(f"FIND ENTITY WITH id='{eid}'", unique=True) # type: ignore def get_entity_by_path(path: str) -> Entity: @@ -49,4 +51,5 @@ def get_entity_by_path(path: str) -> Entity: Submits the query "FIND FILE WHICH IS STORED AT '{path}'". """ - return execute_query(f"FIND FILE WHICH IS STORED AT '{path}'", unique=True) + # type hint can be ignored, it's a unique query + return execute_query(f"FIND FILE WHICH IS STORED AT '{path}'", unique=True) # type: ignore