8000 Add type alias and better naming · localstack/localstack@6ed957b · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ed957b

Browse files
committed
Add type alias and better naming
1 parent a795145 commit 6ed957b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

localstack-core/localstack/utils/batch_policy.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
T = TypeVar("T")
99

10+
# alias to signify whether a batch policy has been triggered
11+
BatchPolicyTriggered = bool
12+
1013

1114
# TODO: Add batching on bytes as well.
1215
@dataclass
@@ -70,13 +73,19 @@ def _check_batch_policy(self) -> bool:
7073
return self._triggered
7174

7275
@overload
73-
def add(self, item: T, *, cache_deep_copy: bool = False) -> bool: ...
76+
def add(self, item: T, *, deep_copy: bool = False) -> BatchPolicyTriggered: ...
7477

7578
@overload
76-
def add(self, items: List[T], *, cache_deep_copy: bool = False) -> bool: ...
79+
def add(self, items: List[T], *, deep_copy: bool = False) -> BatchPolicyTriggered: ...
80+
81+
def add(self, item_or_items: T | list[T], *, deep_copy: bool = False) -> BatchPolicyTriggered:
82+
"""
83+
Add an item or list of items to the collected batch.
7784
78-
def add(self, item_or_items: T | list[T], *, cache_deep_copy: bool = False) -> bool:
79-
if cache_deep_copy:
85+
Returns:
86+
BatchPolicyTriggered: True if the batch policy was triggered during addition, False otherwise.
87+
"""
88+
if deep_copy:
8089
item_or_items = copy.deepcopy(item_or_items)
8190

8291
if isinstance(item_or_items, list):

0 commit comments

Comments
 (0)
0