Skip to content

Commit f709529

Browse files
Making event argument generic and optional arguments Any
1 parent f71450b commit f709529

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

aws_lambda_powertools/shared/types.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from typing_extensions import TypeAlias, get_args, get_origin
2020

2121
AnyCallableT = TypeVar("AnyCallableT", bound=Callable[..., Any]) # noqa: VNE001
22+
23+
2224
# JSON primitives only, mypy doesn't support recursive tho
2325
JSONType = Union[str, int, float, bool, None, Dict[str, Any], List[Any]]
2426

aws_lambda_powertools/tracing/tracer.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
import numbers
77
import os
8-
from typing import Any, Callable, Dict, List, Optional, Sequence, Union, cast, overload
8+
from typing import Any, Callable, Dict, List, Optional, Sequence, TypeVar, Union, cast, overload
99

1010
from aws_lambda_powertools.shared import constants
1111
from aws_lambda_powertools.shared.functions import (
@@ -22,6 +22,8 @@
2222

2323
aws_xray_sdk = LazyLoader(constants.XRAY_SDK_MODULE, globals(), constants.XRAY_SDK_MODULE)
2424

25+
T = TypeVar("T")
26+
2527

2628
class Tracer:
2729
"""Tracer using AWS-XRay to provide decorators with known defaults for Lambda functions
@@ -250,7 +252,7 @@ def patch(self, modules: Optional[Sequence[str]] = None):
250252

251253
def capture_lambda_handler(
252254
self,
253-
lambda_handler: Optional[AnyCallableT] = None,
255+
lambda_handler: Optional[Union[Callable[[T, Any], Any], Callable[[T, Any, Any], Any]]] = None,
254256
capture_response: Optional[bool] = None,
255257
capture_error: Optional[bool] = None,
256258
):

0 commit comments

Comments
 (0)