Skip to content

Commit d743540

Browse files
dependabot[bot]leandrodamascenaclaude
authored
chore(deps-dev): bump ruff from 0.16.10 to 0.17.0 in the dev-dependencies group across 1 directory (#8553)
* chore(deps-dev): bump ruff Bumps the dev-dependencies group with 1 update in the / directory: [ruff](https://github.com/astral-sh/ruff). Updates `ruff` from 0.16.10 to 0.17.0 - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](astral-sh/ruff@0.16.10...0.17.0) --- updated-dependencies: - dependency-name: ruff dependency-version: 0.17.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> * chore(lint): alias datetime imports as dt for ruff 0.17 ICN001 ruff 0.17.0 adds `datetime as dt` to the default flake8-import-conventions aliases, failing `make lint` on every plain `import datetime`. Follow the convention in the 22 affected modules, examples and tests. No behaviour change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Leandro Damascena <lcdama@amazon.pt> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 56c2134 commit d743540

24 files changed

Lines changed: 136 additions & 136 deletions

File tree

‎aws_lambda_powertools/event_handler/openapi/encoders.py‎

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

33
import dataclasses
4-
import datetime
4+
import datetime as dt
55
from collections import defaultdict, deque
66
from decimal import Decimal
77
from enum import Enum
@@ -306,7 +306,7 @@ def _dump_other(
306306
)
307307

308308

309-
def iso_format(o: datetime.date | datetime.time) -> str:
309+
def iso_format(o: dt.date | dt.time) -> str:
310310
"""
311311
ISO format for date and time
312312
"""
@@ -341,10 +341,10 @@ def decimal_encoder(dec_value: Decimal) -> int | float:
341341
str: lambda o: o,
342342
type(None): lambda o: o,
343343
bytes: lambda o: o.decode(),
344-
datetime.date: iso_format,
345-
datetime.datetime: iso_format,
346-
datetime.time: iso_format,
347-
datetime.timedelta: lambda td: td.total_seconds(),
344+
dt.date: iso_format,
345+
dt.datetime: iso_format,
346+
dt.time: iso_format,
347+
dt.timedelta: lambda td: td.total_seconds(),
348348
Decimal: decimal_encoder,
349349
Enum: lambda o: o.value,
350350
PurePath: str,

‎aws_lambda_powertools/metrics/base.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from __future__ import annotations
88

9-
import datetime
9+
import datetime as dt
1010
import functools
1111
import json
1212
import logging
@@ -250,7 +250,7 @@ def serialize_metric_set(
250250

251251
return {
252252
"_aws": {
253-
"Timestamp": self.timestamp or int(datetime.datetime.now().timestamp() * 1000), # epoch
253+
"Timestamp": self.timestamp or int(dt.datetime.now().timestamp() * 1000), # epoch
254254
"CloudWatchMetrics": [
255255
{
256256
"Namespace": self.namespace, # "test_namespace"
@@ -322,7 +322,7 @@ def add_metadata(self, key: str, value: Any) -> None:
322322
else:
323323
self.metadata_set[str(key)] = value
324324

325-
def set_timestamp(self, timestamp: int | datetime.datetime):
325+
def set_timestamp(self, timestamp: int | dt.datetime):
326326
"""
327327
Set the timestamp for the metric.
328328

‎aws_lambda_powertools/metrics/metrics.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from aws_lambda_powertools.metrics.provider.cloudwatch_emf.cloudwatch import AmazonCloudWatchEMFProvider
77

88
if TYPE_CHECKING:
9-
import datetime
9+
import datetime as dt
1010
from collections.abc import Callable
1111

1212
from aws_lambda_powertools.metrics.base import MetricResolution, MetricUnit
@@ -146,7 +146,7 @@ def serialize_metric_set(
146146
def add_metadata(self, key: str, value: Any) -> None:
147147
self.provider.add_metadata(key=key, value=value)
148148

149-
def set_timestamp(self, timestamp: int | datetime.datetime):
149+
def set_timestamp(self, timestamp: int | dt.datetime):
150150
"""
151151
Set the timestamp for the metric.
152152

‎aws_lambda_powertools/metrics/provider/cloudwatch_emf/cloudwatch.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
import datetime
3+
import datetime as dt
44
import json
55
import logging
66
import numbers
@@ -272,7 +272,7 @@ def serialize_metric_set(
272272

273273
return {
274274
"_aws": {
275-
"Timestamp": self.timestamp or int(datetime.datetime.now().timestamp() * 1000), # epoch
275+
"Timestamp": self.timestamp or int(dt.datetime.now().timestamp() * 1000), # epoch
276276
"CloudWatchMetrics": [
277277
{
278278
"Namespace": self.namespace, # "test_namespace"
@@ -426,7 +426,7 @@ def add_metadata(self, key: str, value: Any) -> None:
426426
else:
427427
self.metadata_set[str(key)] = value
428428

429-
def set_timestamp(self, timestamp: int | datetime.datetime):
429+
def set_timestamp(self, timestamp: int | dt.datetime):
430430
"""
431431
Set the timestamp for the metric.
432432

‎aws_lambda_powertools/utilities/circuit_breaker/base.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from __future__ import annotations
1010

11-
import datetime
11+
import datetime as dt
1212
import logging
1313
import os
1414
import threading
@@ -281,4 +281,4 @@ def _notify(self, from_state: CircuitState, to_state: CircuitState, opened_at: i
281281
@staticmethod
282282
def _now() -> int:
283283
"""Current unix timestamp in seconds."""
284-
return int(datetime.datetime.now().timestamp())
284+
return int(dt.datetime.now().timestamp())

‎aws_lambda_powertools/utilities/circuit_breaker/persistence/base.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from __future__ import annotations
1010

11-
import datetime
11+
import datetime as dt
1212
import logging
1313
import threading
1414
from abc import ABC, abstractmethod
@@ -114,12 +114,12 @@ def _durable_ttl(self, name: str) -> int:
114114
Sized to outlive a full recovery window so a live circuit is never reaped
115115
mid-cycle, while an abandoned circuit (no further writes) self-cleans soon after.
116116
"""
117-
now = int(datetime.datetime.now().timestamp())
117+
now = int(dt.datetime.now().timestamp())
118118
return now + self._settings_for(name).recovery_timeout + PERSISTED_STATE_TTL_BUFFER
119119

120120
def _save_to_cache(self, record: CircuitStateRecord) -> None:
121121
"""Cache a record locally with a short in-memory freshness window."""
122-
local_expiry = int(datetime.datetime.now().timestamp()) + self._settings_for(record.name).local_cache_max_age
122+
local_expiry = int(dt.datetime.now().timestamp()) + self._settings_for(record.name).local_cache_max_age
123123
with self._lock:
124124
self._cache[self._cache_key(record.name)] = (local_expiry, record)
125125

@@ -131,7 +131,7 @@ def _retrieve_from_cache(self, name: str) -> CircuitStateRecord | None:
131131
return None
132132

133133
local_expiry, record = cached
134-
if int(datetime.datetime.now().timestamp()) >= local_expiry:
134+
if int(dt.datetime.now().timestamp()) >= local_expiry:
135135
# Guarded del, not pop: on Python 3.10 OrderedDict.pop re-enters the
136136
# subclass __getitem__ after detaching the node, so LRUDict.pop raises
137137
# KeyError for a *present* key and corrupts the dict (fixed in 3.11).
@@ -242,7 +242,7 @@ def try_acquire_half_open(self, name: str, owner: str, opened_at: int) -> bool:
242242
worker already holds it.
243243
"""
244244
# Lease = recovery_timeout gives the probe a full cycle to complete.
245-
probe_lease_expiry = int(datetime.datetime.now().timestamp()) + self._settings_for(name).recovery_timeout
245+
probe_lease_expiry = int(dt.datetime.now().timestamp()) + self._settings_for(name).recovery_timeout
246246
record = CircuitStateRecord(
247247
name=name,
248248
state=CircuitState.HALF_OPEN,

‎aws_lambda_powertools/utilities/circuit_breaker/persistence/dynamodb.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from __future__ import annotations
66

7-
import datetime
7+
import datetime as dt
88
import logging
99
import os
1010
import warnings
@@ -215,7 +215,7 @@ def _build_half_open_condition(self, expected_opened_at: int | None = None) -> d
215215
expression_values: dict = {
216216
":open": self._s(str(CircuitState.OPEN)),
217217
":half_open": self._s(str(CircuitState.HALF_OPEN)),
218-
":now": self._n(int(datetime.datetime.now().timestamp())),
218+
":now": self._n(int(dt.datetime.now().timestamp())),
219219
}
220220

221221
if expected_opened_at is not None:

‎aws_lambda_powertools/utilities/data_classes/appsync/scalar_types_utils.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import datetime
1+
import datetime as dt
22
import time
33
import uuid
44

55

6-
def _formatted_time(now: datetime.date, fmt: str, timezone_offset: int) -> str:
6+
def _formatted_time(now: dt.date, fmt: str, timezone_offset: int) -> str:
77
"""String formatted time with optional timezone offset
88
99
Parameters
@@ -20,7 +20,7 @@ def _formatted_time(now: datetime.date, fmt: str, timezone_offset: int) -> str:
2020
Returns string formatted time with optional timezone offset
2121
"""
2222
if timezone_offset != 0:
23-
now = now + datetime.timedelta(hours=timezone_offset)
23+
now = now + dt.timedelta(hours=timezone_offset)
2424

2525
datetime_str = now.strftime(fmt)
2626
if fmt.endswith(".%f"):
@@ -55,7 +55,7 @@ def aws_date(timezone_offset: int = 0) -> str:
5555
str
5656
Returns current time as AWSDate scalar string with optional timezone offset
5757
"""
58-
return _formatted_time(datetime.datetime.now(datetime.timezone.utc), "%Y-%m-%d", timezone_offset)
58+
return _formatted_time(dt.datetime.now(dt.timezone.utc), "%Y-%m-%d", timezone_offset)
5959

6060

6161
def aws_time(timezone_offset: int = 0) -> str:
@@ -71,7 +71,7 @@ def aws_time(timezone_offset: int = 0) -> str:
7171
str
7272
Returns current time as AWSTime scalar string with optional timezone offset
7373
"""
74-
return _formatted_time(datetime.datetime.now(datetime.timezone.utc), "%H:%M:%S.%f", timezone_offset)
74+
return _formatted_time(dt.datetime.now(dt.timezone.utc), "%H:%M:%S.%f", timezone_offset)
7575

7676

7777
def aws_datetime(timezone_offset: int = 0) -> str:
@@ -87,7 +87,7 @@ def aws_datetime(timezone_offset: int = 0) -> str:
8787
str
8888
Returns current time as AWSDateTime scalar string with optional timezone offset
8989
"""
90-
return _formatted_time(datetime.datetime.now(datetime.timezone.utc), "%Y-%m-%dT%H:%M:%S.%f", timezone_offset)
90+
return _formatted_time(dt.datetime.now(dt.timezone.utc), "%Y-%m-%dT%H:%M:%S.%f", timezone_offset)
9191

9292

9393
def aws_timestamp() -> int:

‎aws_lambda_powertools/utilities/idempotency/base.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from __future__ import annotations
88

9-
import datetime
9+
import datetime as dt
1010
import logging
1111
from copy import deepcopy
1212
from typing import TYPE_CHECKING, Any
@@ -255,7 +255,7 @@ def _handle_for_status(self, data_record: DataRecord) -> Any | None:
255255

256256
if data_record.status == STATUS_CONSTANTS["INPROGRESS"]:
257257
if data_record.in_progress_expiry_timestamp is not None and data_record.in_progress_expiry_timestamp < int(
258-
datetime.datetime.now().timestamp() * 1000,
258+
dt.datetime.now().timestamp() * 1000,
259259
):
260260
raise IdempotencyInconsistentStateError(
261261
"item should have been expired in-progress because it already time-outed.",

‎aws_lambda_powertools/utilities/idempotency/persistence/base.py‎

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

55
from __future__ import annotations
66

7-
import datetime
7+
import datetime as dt
88
import hashlib
99
import json
1010
import logging
@@ -48,7 +48,7 @@ def default(self, obj: Any) -> Any:
4848
except TypeError:
4949
if isinstance(obj, Enum):
5050
return obj.value
51-
if isinstance(obj, (datetime.date, datetime.time)):
51+
if isinstance(obj, (dt.date, dt.time)):
5252
return obj.isoformat()
5353
if isinstance(obj, (UUID, PurePath)):
5454
return str(obj)
@@ -240,8 +240,8 @@ def _get_expiry_timestamp(self) -> int:
240240
unix timestamp of expiry date for idempotency record
241241
242242
"""
243-
now = datetime.datetime.now()
244-
period = datetime.timedelta(seconds=self.expires_after_seconds)
243+
now = dt.datetime.now()
244+
period = dt.timedelta(seconds=self.expires_after_seconds)
245245
return int((now + period).timestamp())
246246

247247
def _save_to_cache(self, data_record: DataRecord):
@@ -345,8 +345,8 @@ def save_inprogress(self, data: dict[str, Any], remaining_time_in_millis: int |
345345
# Therefore, we need to check if remaining_time_in_millis is not None (>=0) to handle this case.
346346
# See: https://github.com/aws-powertools/powertools-lambda-python/issues/4759
347347
if remaining_time_in_millis is not None:
348-
now = datetime.datetime.now()
349-
period = datetime.timedelta(milliseconds=remaining_time_in_millis)
348+
now = dt.datetime.now()
349+
period = dt.timedelta(milliseconds=remaining_time_in_millis)
350350
timestamp = (now + period).timestamp()
351351
data_record.in_progress_expiry_timestamp = int(timestamp * 1000)
352352
else:

0 commit comments

Comments
 (0)