This is an automated email from the ASF dual-hosted git repository. potiuk pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push: new decc6d9414 Improve typing hints for only_client_type decorator (#35997) decc6d9414 is described below commit decc6d94141569268585b044e49be224f5718408 Author: Hussein Awala <huss...@awala.fr> AuthorDate: Fri Dec 1 16:44:34 2023 +0200 Improve typing hints for only_client_type decorator (#35997) --- airflow/providers/amazon/aws/hooks/ec2.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/airflow/providers/amazon/aws/hooks/ec2.py b/airflow/providers/amazon/aws/hooks/ec2.py index 4fdf409bbb..cd13f007c4 100644 --- a/airflow/providers/amazon/aws/hooks/ec2.py +++ b/airflow/providers/amazon/aws/hooks/ec2.py @@ -19,16 +19,21 @@ from __future__ import annotations import functools import time +from typing import Callable, TypeVar from airflow.exceptions import AirflowException from airflow.providers.amazon.aws.hooks.base_aws import AwsBaseHook +from airflow.typing_compat import ParamSpec +PS = ParamSpec("PS") +RT = TypeVar("RT") -def only_client_type(func): + +def only_client_type(func: Callable[PS, RT]) -> Callable[PS, RT]: @functools.wraps(func) - def checker(self, *args, **kwargs): - if self._api_type == "client_type": - return func(self, *args, **kwargs) + def checker(*args, **kwargs) -> RT: + if args[0]._api_type == "client_type": + return func(*args, **kwargs) ec2_doc_link = "https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html" raise AirflowException(