Skip to content

Commit 8bce440

Browse files
Adding shared
1 parent 9423510 commit 8bce440

10 files changed

+28
-8
lines changed

aws_lambda_powertools/shared/dynamodb_deserializer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from __future__ import annotations
22

33
from decimal import Clamped, Context, Decimal, Inexact, Overflow, Rounded, Underflow
4-
from typing import Any, Callable, Sequence
4+
from typing import TYPE_CHECKING, Any
5+
6+
if TYPE_CHECKING:
7+
from collections.abc import Callable, Sequence
58

69
# NOTE: DynamoDB supports up to 38 digits precision
710
# Therefore, this ensures our Decimal follows what's stored in the table

aws_lambda_powertools/shared/functions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
import warnings
99
from binascii import Error as BinAsciiError
1010
from pathlib import Path
11-
from typing import Any, Generator, overload
11+
from typing import TYPE_CHECKING, Any, overload
1212

1313
from aws_lambda_powertools.shared import constants
1414

15+
if TYPE_CHECKING:
16+
from collections.abc import Generator
17+
1518
logger = logging.getLogger(__name__)
1619

1720

aws_lambda_powertools/shared/types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
from typing import Any, Callable, TypeVar
1+
from collections.abc import Callable
2+
from typing import Any, TypeVar
23

3-
AnyCallableT = TypeVar("AnyCallableT", bound=Callable[..., Any]) # noqa: VNE001
4+
AnyCallableT = TypeVar("AnyCallableT", bound=Callable[..., Any])

aws_lambda_powertools/utilities/serialization.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import base64
44
import json
5-
from typing import Any, Callable
5+
from collections.abc import Callable
6+
from typing import Any
67

78

89
def base64_encode(data: str) -> str:

tests/unit/shared/test_dynamodb_deserializer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from typing import Any, Dict, Optional
1+
from __future__ import annotations
2+
3+
from typing import Any
24

35
import pytest
46

@@ -10,14 +12,14 @@ def __init__(self, data: dict):
1012
self._data = data
1113
self._deserializer = TypeDeserializer()
1214

13-
def _deserialize_dynamodb_dict(self) -> Optional[Dict[str, Any]]:
15+
def _deserialize_dynamodb_dict(self) -> dict[str, Any] | None:
1416
if self._data is None:
1517
return None
1618

1719
return {k: self._deserializer.deserialize(v) for k, v in self._data.items()}
1820

1921
@property
20-
def data(self) -> Optional[Dict[str, Any]]:
22+
def data(self) -> dict[str, Any] | None:
2123
"""The primary key attribute(s) for the DynamoDB item that was modified."""
2224
return self._deserialize_dynamodb_dict()
2325

tests/unit/test_cookie_class.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from datetime import datetime
24

35
from aws_lambda_powertools.shared.cookies import Cookie, SameSite

tests/unit/test_data_classes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import base64
24
import datetime
35
import json

tests/unit/test_json_encoder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import decimal
24
import json
35
from dataclasses import dataclass

tests/unit/test_lru_cache.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import random
24
import sys
35

tests/unit/test_shared_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import os
24
import warnings
35
from dataclasses import dataclass

0 commit comments

Comments
 (0)