Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit e3f4ec2

Browse files
authored
typing: update Events and STS typing (#13862)
1 parent cde582c commit e3f4ec2

3 files changed

Lines changed: 14 additions & 24 deletions

File tree

localstack-core/localstack/services/events/event_bus.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
from datetime import UTC, datetime
3-
from typing import Self
3+
from typing import Any, Self
44

55
from localstack.aws.api.events import (
66
Action,
@@ -12,7 +12,7 @@
1212
StatementId,
1313
TagList,
1414
)
15-
from localstack.services.events.models import EventBus, ResourcePolicy, RuleDict, Statement
15+
from localstack.services.events.models import EventBus, ResourcePolicy, RuleDict
1616
from localstack.utils.aws.arns import get_partition
1717

1818

@@ -111,21 +111,20 @@ def _parse_statement(
111111
principal: Principal,
112112
resource_arn: Arn,
113113
condition: Condition,
114-
) -> Statement:
114+
) -> dict[str, Any]:
115115
# TODO: cover via test
116116
# if condition and principal != "*":
117117
# raise ValueError("Condition can only be set when principal is '*'")
118118
if principal != "*":
119119
principal = {"AWS": f"arn:{get_partition(self.event_bus.region)}:iam::{principal}:root"}
120-
statement = Statement(
121-
Sid=statement_id,
122-
Effect="Allow",
123-
Principal=principal,
124-
Action=action,
125-
Resource=resource_arn,
126-
Condition=condition,
127-
)
128-
return statement
120+
return {
121+
"Sid": statement_id,
122+
"Effect": "Allow",
123+
"Principal": principal,
124+
"Action": action,
125+
"Resource": resource_arn,
126+
"Condition": condition,
127+
}
129128

130129

131130
EventBusServiceDict = dict[Arn, EventBusService]

localstack-core/localstack/services/events/models.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,9 @@ class ResourceType(Enum):
107107
RULE = "rule"
108108

109109

110-
class Statement(TypedDict):
111-
Sid: str | None
112-
Effect: str
113-
Principal: str | dict[str, str] | None
114-
Action: str | list[str]
115-
Resource: str | list[str]
116-
Condition: dict[str, Any] | None
117-
118-
119110
class ResourcePolicy(TypedDict):
120111
Version: str
121-
Statement: list[Statement]
112+
Statement: list[dict[str, Any]]
122113

123114

124115
@dataclass

localstack-core/localstack/services/sts/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TypedDict
1+
from typing import Any, TypedDict
22

33
from localstack.aws.api.sts import Tag
44
from localstack.services.stores import AccountRegionBundle, BaseStore, CrossRegionAttribute
@@ -10,7 +10,7 @@ class SessionConfig(TypedDict):
1010
# list of lowercase transitive tag keys
1111
transitive_tags: list[str]
1212
# other stored context variables
13-
iam_context: dict[str, str | list[str]]
13+
iam_context: dict[str, Any]
1414

1515

1616
class STSStore(BaseStore):

0 commit comments

Comments
 (0)