Skip to content

Commit

Permalink
Improve typing hints for only_client_type decorator (#35997)
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-awala committed Dec 1, 2023
1 parent b1e547e commit decc6d9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions airflow/providers/amazon/aws/hooks/ec2.py
Expand Up @@ -19,16 +19,21 @@

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(
Expand Down

0 comments on commit decc6d9

Please sign in to comment.