Skip to content

Commit 46414a8

Browse files
authored
refactor(typing): add from __future__ import annotations (#4985)
and update code according to ruff rules TCH, UP006, UP007, UP037 and FA100.
1 parent 0fb2fc0 commit 46414a8

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
# -*- coding: utf-8 -*-
2-
from typing import Any, Dict
2+
from __future__ import annotations
33

4-
from aws_lambda_powertools.utilities.typing.lambda_client_context_mobile_client import (
5-
LambdaClientContextMobileClient,
6-
)
4+
from typing import TYPE_CHECKING, Any
5+
6+
if TYPE_CHECKING:
7+
from aws_lambda_powertools.utilities.typing.lambda_client_context_mobile_client import (
8+
LambdaClientContextMobileClient,
9+
)
710

811

912
class LambdaClientContext(object):
1013
_client: LambdaClientContextMobileClient
11-
_custom: Dict[str, Any]
12-
_env: Dict[str, Any]
14+
_custom: dict[str, Any]
15+
_env: dict[str, Any]
1316

1417
@property
1518
def client(self) -> LambdaClientContextMobileClient:
1619
"""Client context that's provided to Lambda by the client application."""
1720
return self._client
1821

1922
@property
20-
def custom(self) -> Dict[str, Any]:
23+
def custom(self) -> dict[str, Any]:
2124
"""A dict of custom values set by the mobile client application."""
2225
return self._custom
2326

2427
@property
25-
def env(self) -> Dict[str, Any]:
28+
def env(self) -> dict[str, Any]:
2629
"""A dict of environment information provided by the AWS SDK."""
2730
return self._env

aws_lambda_powertools/utilities/typing/lambda_context.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# -*- coding: utf-8 -*-
2-
from aws_lambda_powertools.utilities.typing.lambda_client_context import (
3-
LambdaClientContext,
4-
)
5-
from aws_lambda_powertools.utilities.typing.lambda_cognito_identity import (
6-
LambdaCognitoIdentity,
7-
)
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from aws_lambda_powertools.utilities.typing.lambda_client_context import (
8+
LambdaClientContext,
9+
)
10+
from aws_lambda_powertools.utilities.typing.lambda_cognito_identity import (
11+
LambdaCognitoIdentity,
12+
)
813

914

1015
class LambdaContext(object):
@@ -14,10 +19,10 @@ class LambdaContext(object):
1419
-------
1520
**A Lambda function using LambdaContext**
1621
17-
>>> from typing import Any, Dict
22+
>>> from typing import Any
1823
>>> from aws_lambda_powertools.utilities.typing import LambdaContext
1924
>>>
20-
>>> def handler(event: Dict[str, Any], context: LambdaContext) -> Dict[str, Any]:
25+
>>> def handler(event: dict[str, Any], context: LambdaContext) -> dict[str, Any]:
2126
>>> # Insert business logic
2227
>>> return event
2328

0 commit comments

Comments
 (0)