Skip to content

Commit d413f61

Browse files
authored
Merge pull request #1289 from tisnik/lcore-1433-fixed-linter-issue
LCORE- 1433: fixed linter issue + enable new linter rule
2 parents 64bb63a + 2936c75 commit d413f61

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ disable = ["R0801"]
223223
extend-exclude = ["tests/profiles/syntax_error.py"]
224224

225225
[tool.ruff.lint]
226-
extend-select = ["TID251", "UP006", "UP007", "UP035", "RUF100"]
226+
extend-select = ["TID251", "UP006", "UP007", "UP017", "UP035", "RUF100"]
227227

228228
[tool.ruff.lint.flake8-tidy-imports.banned-api]
229229
unittest = { msg = "use pytest instead of unittest" }

src/app/endpoints/a2a.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import uuid
66
from collections.abc import Mapping, AsyncIterator, MutableMapping
7-
from datetime import datetime, timezone
7+
from datetime import datetime, UTC
88
from typing import Annotated, Any, Optional
99

1010
from a2a.server.agent_execution import AgentExecutor, RequestContext
@@ -381,7 +381,7 @@ async def _process_task_streaming( # pylint: disable=too-many-locals
381381
task_id=task_id,
382382
status=TaskStatus(
383383
state=TaskState.working,
384-
timestamp=datetime.now(timezone.utc).isoformat(),
384+
timestamp=datetime.now(UTC).isoformat(),
385385
),
386386
context_id=context_id,
387387
final=False,
@@ -403,14 +403,14 @@ async def _process_task_streaming( # pylint: disable=too-many-locals
403403
if aggregator.task_state == TaskState.working:
404404
await task_updater.update_status(
405405
TaskState.completed,
406-
timestamp=datetime.now(timezone.utc).isoformat(),
406+
timestamp=datetime.now(UTC).isoformat(),
407407
final=True,
408408
)
409409
else:
410410
await task_updater.update_status(
411411
aggregator.task_state,
412412
message=aggregator.task_status_message,
413-
timestamp=datetime.now(timezone.utc).isoformat(),
413+
timestamp=datetime.now(UTC).isoformat(),
414414
final=True,
415415
)
416416

@@ -459,7 +459,7 @@ async def _convert_stream_to_events( # pylint: disable=too-many-branches,too-ma
459459
context_id=context_id,
460460
task_id=task_id,
461461
),
462-
timestamp=datetime.now(timezone.utc).isoformat(),
462+
timestamp=datetime.now(UTC).isoformat(),
463463
),
464464
context_id=context_id,
465465
final=False,
@@ -477,7 +477,7 @@ async def _convert_stream_to_events( # pylint: disable=too-many-branches,too-ma
477477
context_id=context_id,
478478
task_id=task_id,
479479
),
480-
timestamp=datetime.now(timezone.utc).isoformat(),
480+
timestamp=datetime.now(UTC).isoformat(),
481481
),
482482
context_id=context_id,
483483
final=False,
@@ -495,7 +495,7 @@ async def _convert_stream_to_events( # pylint: disable=too-many-branches,too-ma
495495
context_id=context_id,
496496
task_id=task_id,
497497
),
498-
timestamp=datetime.now(timezone.utc).isoformat(),
498+
timestamp=datetime.now(UTC).isoformat(),
499499
),
500500
context_id=context_id,
501501
final=False,
@@ -891,5 +891,5 @@ async def a2a_health_check() -> dict[str, str]:
891891
"service": "lightspeed-a2a",
892892
"version": __version__,
893893
"a2a_sdk_version": "0.3.4",
894-
"timestamp": datetime.now(timezone.utc).isoformat(),
894+
"timestamp": datetime.now(UTC).isoformat(),
895895
}

src/app/endpoints/query.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ async def query_endpoint_handler(
237237
quota_limiters=configuration.quota_limiters, user_id=user_id
238238
)
239239

240-
completed_at = datetime.datetime.now(datetime.timezone.utc).strftime(
241-
"%Y-%m-%dT%H:%M:%SZ"
242-
)
240+
completed_at = datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%dT%H:%M:%SZ")
243241
conversation_id = normalize_conversation_id(responses_params.conversation)
244242

245243
logger.info("Storing query results")

tests/unit/app/endpoints/test_conversations_v2.py

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

33
"""Unit tests for the /conversations REST API endpoints."""
44

5-
from datetime import datetime, timezone
5+
from datetime import datetime, UTC
66
from typing import Any, cast
77

88
import pytest
@@ -361,9 +361,7 @@ async def test_successful_retrieval(
361361
mocker.patch("app.endpoints.conversations_v2.configuration", mock_configuration)
362362

363363
timestamp_str = "2024-01-01T00:00:00Z"
364-
timestamp_dt = datetime.fromisoformat(timestamp_str).replace(
365-
tzinfo=timezone.utc
366-
)
364+
timestamp_dt = datetime.fromisoformat(timestamp_str).replace(tzinfo=UTC)
367365
timestamp = timestamp_dt.timestamp()
368366

369367
mock_configuration.conversation_cache.list.return_value = [

0 commit comments

Comments
 (0)