Skip to content

Commit

Permalink
Merge #956
Browse files Browse the repository at this point in the history
956: Fix reported type of decorator r=curquiza a=sanders41

# Pull Request

## Related issue
Fixes #<issue_number>

Reported on Discord https://discord.com/channels/1006923006964154428/1006923007559729154/1235605897418506401

The Return type is getting swallowed by the `version_error_hint_message` decorator.

![image](https://github.com/meilisearch/meilisearch-python/assets/25045024/1467c6b1-3d86-449a-ba6c-15b2a7c33777)

## What does this PR do?
- Uses a generic instead of `Any` for the decorator.

After the update:

![image](https://github.com/meilisearch/meilisearch-python/assets/25045024/3eb434a2-08ab-46fd-8bd1-24db11e8ce64)

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: Paul Sanders <paul@paulsanders.dev>
  • Loading branch information
meili-bors[bot] and sanders41 committed May 2, 2024
2 parents a3401ae + 036296f commit 8dc5b34
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions meilisearch/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json
from functools import wraps
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any, Callable, TypeVar

from requests import Response

Expand All @@ -11,6 +11,8 @@
from meilisearch.index import Index
from meilisearch.task import TaskHandler

T = TypeVar("T")


class MeilisearchError(Exception): # pragma: no cover
"""Generic class for Meilisearch error handling"""
Expand Down Expand Up @@ -63,7 +65,7 @@ def __str__(self) -> str: # pragma: no cover
return f"MeilisearchTimeoutError, {self.message}"


def version_error_hint_message(func: Callable) -> Any:
def version_error_hint_message(func: Callable[..., T]) -> Callable[..., T]:
@wraps(func)
def wrapper(*args: Any, **kwargs: Any) -> Any:
try:
Expand Down

0 comments on commit 8dc5b34

Please sign in to comment.