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

Commit 26619a9

Browse files
authored
Update ruff target-version to 3.13 (#13688)
1 parent 2a499fd commit 26619a9

File tree

20 files changed

+42
-78
lines changed

20 files changed

+42
-78
lines changed

localstack-core/localstack/aws/connect.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from functools import lru_cache, partial
1616
from random import choice
1717
from socket import socket
18-
from typing import Any, Generic, TypedDict, TypeVar
18+
from typing import Any, TypedDict
1919

2020
import dns.message
2121
import dns.query
@@ -165,10 +165,7 @@ def load_dto(data: str) -> InternalRequestParameters:
165165
return json.loads(data)
166166

167167

168-
T = TypeVar("T")
169-
170-
171-
class MetadataRequestInjector(Generic[T]):
168+
class MetadataRequestInjector[T]:
172169
def __init__(self, client: T, params: dict[str, str] | None = None):
173170
self._client = client
174171
self._params = params

localstack-core/localstack/aws/protocol/routing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import re
2-
from typing import AnyStr
32

43
from werkzeug.routing import Rule
54

@@ -30,7 +29,7 @@ def __init__(self, string: str, method: str, **kwargs) -> None:
3029
self.methods = {method.upper()}
3130

3231

33-
def transform_path_params_to_rule_vars(match: re.Match[AnyStr]) -> str:
32+
def transform_path_params_to_rule_vars(match: re.Match[str]) -> str:
3433
"""
3534
Transforms a request URI path param to a valid Werkzeug Rule string variable placeholder.
3635
This transformation function should be used in combination with _path_param_regex on the request URIs (without any

localstack-core/localstack/aws/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def load_service(
142142
return ServiceModel(service_description, service)
143143

144144

145-
def iterate_service_operations() -> Generator[tuple[ServiceModel, OperationModel], None, None]:
145+
def iterate_service_operations() -> Generator[tuple[ServiceModel, OperationModel]]:
146146
"""
147147
Returns one record per operation in the AWS service spec, where the first item is the service model the operation
148148
belongs to, and the second is the operation model.

localstack-core/localstack/services/cloudformation/engine/v2/change_set_model.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import enum
55
from collections.abc import Generator
66
from itertools import zip_longest
7-
from typing import Any, Final, TypedDict, cast
8-
9-
from typing_extensions import TypeVar
7+
from typing import Any, Final, TypedDict, TypeVar, cast
108

119
from localstack.aws.api.cloudformation import ChangeAction
1210
from localstack.services.cloudformation.resource_provider import ResourceProviderExecutor

localstack-core/localstack/services/cloudformation/engine/v2/change_set_model_preproc.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import copy
55
import re
66
from collections.abc import Callable
7-
from typing import Any, Final, Generic, TypeVar
7+
from typing import Any, Final
88

99
from botocore.exceptions import ClientError
1010

@@ -79,9 +79,6 @@
7979
"AWS::NotificationARNs",
8080
}
8181

82-
TBefore = TypeVar("TBefore")
83-
TAfter = TypeVar("TAfter")
84-
_T = TypeVar("_T")
8582

8683
REGEX_OUTPUT_APIGATEWAY = re.compile(
8784
rf"^(https?://.+\.execute-api\.)(?:[^-]+-){{2,3}}\d\.(amazonaws\.com|{_AWS_URL_SUFFIX})/?(.*)$"
@@ -91,7 +88,7 @@
9188
VALID_LOGICAL_RESOURCE_ID_RE = re.compile(r"^[A-Za-z0-9]+$")
9289

9390

94-
class PreprocEntityDelta(Generic[TBefore, TAfter]):
91+
class PreprocEntityDelta[TBefore, TAfter]:
9592
before: Maybe[TBefore]
9693
after: Maybe[TAfter]
9794

@@ -432,16 +429,16 @@ def _maybe_perform_static_replacements(self, delta: PreprocEntityDelta) -> Prepr
432429
def _maybe_perform_dynamic_replacements(self, delta: PreprocEntityDelta) -> PreprocEntityDelta:
433430
return self._maybe_perform_on_delta(delta, self._perform_dynamic_replacements)
434431

435-
def _maybe_perform_on_delta(
436-
self, delta: PreprocEntityDelta | None, f: Callable[[_T], _T]
432+
def _maybe_perform_on_delta[T](
433+
self, delta: PreprocEntityDelta | None, f: Callable[[T], T]
437434
) -> PreprocEntityDelta | None:
438435
if isinstance(delta.before, str):
439436
delta.before = f(delta.before)
440437
if isinstance(delta.after, str):
441438
delta.after = f(delta.after)
442439
return delta
443440

444-
def _perform_dynamic_replacements(self, value: _T) -> _T:
441+
def _perform_dynamic_replacements[T](self, value: T) -> T:
445442
if not isinstance(value, str):
446443
return value
447444

localstack-core/localstack/services/cloudformation/resource_provider.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from enum import Enum, auto
1111
from logging import Logger
1212
from math import ceil
13-
from typing import TYPE_CHECKING, Any, Generic, TypedDict, TypeVar
13+
from typing import TYPE_CHECKING, Any, TypedDict, TypeVar
1414

1515
import botocore
1616
from botocore.client import BaseClient
@@ -65,7 +65,7 @@ class OperationStatus(Enum):
6565

6666

6767
@dataclass
68-
class ProgressEvent(Generic[Properties]):
68+
class ProgressEvent[Properties]:
6969
status: OperationStatus
7070
resource_model: Properties | None = None
7171
resource_models: list[Properties] | None = None
@@ -165,7 +165,7 @@ def convert_payload(
165165

166166

167167
@dataclass
168-
class ResourceRequest(Generic[Properties]):
168+
class ResourceRequest[Properties]:
169169
_original_payload: Properties
170170

171171
aws_client_factory: ServiceLevelClientFactory
@@ -198,7 +198,7 @@ class CloudFormationResourceProviderPlugin(Plugin):
198198
namespace = "localstack.cloudformation.resource_providers"
199199

200200

201-
class ResourceProvider(Generic[Properties]):
201+
class ResourceProvider[Properties]:
202202
"""
203203
This provides a base class onto which service-specific resource providers are built.
204204
"""
@@ -401,7 +401,7 @@ class NoResourceProvider(Exception):
401401
pass
402402

403403

404-
def resolve_json_pointer(resource_props: Properties, primary_id_path: str) -> str:
404+
def resolve_json_pointer[Properties](resource_props: Properties, primary_id_path: str) -> str:
405405
primary_id_path = primary_id_path.replace("/properties", "")
406406
parts = [p for p in primary_id_path.split("/") if p]
407407

localstack-core/localstack/services/cloudformation/scaffolding/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def render(
420420
self.environment, template_mapping[file_type], **kwargs
421421
)
422422

423-
def get_getatt_targets(self) -> Generator[str, None, None]:
423+
def get_getatt_targets(self) -> Generator[str]:
424424
for name, defn in self.schema["properties"].items():
425425
if "type" in defn and defn["type"] in ["string"]:
426426
yield name

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from dataclasses import dataclass, field
33
from datetime import UTC, datetime
44
from enum import Enum
5-
from typing import Literal, TypeAlias, TypedDict
5+
from typing import Literal, TypedDict
66

77
from localstack.aws.api import CommonServiceException
88
from localstack.aws.api.events import (
@@ -100,7 +100,7 @@ def __init__(self, reason=None, message=None) -> None:
100100
FormattedEventDict = dict[str, FormattedEvent]
101101
FormattedEventList = list[FormattedEvent]
102102

103-
TransformedEvent: TypeAlias = FormattedEvent | dict | str
103+
type TransformedEvent = FormattedEvent | dict | str
104104

105105

106106
class ResourceType(Enum):

localstack-core/localstack/services/kms/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import re
22
from collections.abc import Callable
3-
from typing import TypeVar
43

54
from localstack.aws.api.kms import DryRunOperationException, Tag, TagException
65
from localstack.services.kms.exceptions import ValidationException
76
from localstack.utils.aws.arns import ARN_PARTITION_REGEX
87

9-
T = TypeVar("T")
10-
118
KMS_KEY_ARN_PATTERN = re.compile(
129
rf"{ARN_PARTITION_REGEX}:kms:(?P<region_name>[^:]+):(?P<account_id>\d{{12}}):((?=key/)key/|(?=alias/))(?P<key_id>[^:]+)$"
1310
)
@@ -63,7 +60,7 @@ def validate_tag(tag_position: int, tag: Tag) -> None:
6360
raise TagException("Tags beginning with aws: are reserved")
6461

6562

66-
def execute_dry_run_capable(func: Callable[..., T], dry_run: bool, *args, **kwargs) -> T:
63+
def execute_dry_run_capable[T](func: Callable[..., T], dry_run: bool, *args, **kwargs) -> T:
6764
"""
6865
Executes a function unless dry run mode is enabled.
6966

localstack-core/localstack/services/sqs/queue.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import time
22
from queue import Empty, PriorityQueue, Queue
3-
from typing import Generic, TypeVar
43

5-
T = TypeVar("T")
64

7-
8-
class InterruptibleQueue(Queue, Generic[T]):
5+
class InterruptibleQueue[T](Queue):
96
# is_shutdown is used to check whether we have triggered a shutdown of the Queue
107
is_shutdown: bool
118

@@ -49,5 +46,5 @@ def shutdown(self) -> None:
4946
self.not_empty.notify_all()
5047

5148

52-
class InterruptiblePriorityQueue(PriorityQueue, InterruptibleQueue[T], Generic[T]):
49+
class InterruptiblePriorityQueue[T](PriorityQueue[T], InterruptibleQueue[T]):
5350
pass

0 commit comments

Comments
 (0)