From 3e80d6a0f71b6cde8f539150bffffe9ee338253b Mon Sep 17 00:00:00 2001 From: qthequartermasterman Date: Wed, 8 May 2024 21:47:43 -0500 Subject: [PATCH] fix: :label: fix incorrect decorator typing --- hypothesis_torch/huggingface.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hypothesis_torch/huggingface.py b/hypothesis_torch/huggingface.py index fe47cf7..711e334 100644 --- a/hypothesis_torch/huggingface.py +++ b/hypothesis_torch/huggingface.py @@ -5,8 +5,8 @@ import transformers.activations import inspect -from typing import TypeVar -from typing_extensions import Final +from typing import TypeVar, Callable +from typing_extensions import Final, ParamSpec import hypothesis import hypothesis.strategies as st @@ -15,6 +15,7 @@ from hypothesis_torch import inspection_util +P = ParamSpec("P") T = TypeVar("T") TransformerType = TypeVar("TransformerType", bound=transformers.PreTrainedModel) @@ -96,8 +97,8 @@ def ignore_errors(*errors_to_ignore: type[Exception]): """Decorator to ignore import errors.""" - def decorator(func): - def wrapper(*args, **kwargs): + def decorator(func: Callable[P, T]) -> Callable[P, T]: + def wrapper(*args: P.args, **kwargs: P.kwargs) -> T: try: return func(*args, **kwargs) except errors_to_ignore as e: