From 8c6fdda64629c2fa2fb2f403f8110b00413bfd67 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 12:12:17 +0000 Subject: [PATCH] Fix linting and formatting issues Co-authored-by: MischaPanch <35432522+MischaPanch@users.noreply.github.com> --- src/serena/dashboard.py | 18 +++++++++--------- test/serena/test_dashboard.py | 4 +--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/serena/dashboard.py b/src/serena/dashboard.py index df72dbda..190f1b1d 100644 --- a/src/serena/dashboard.py +++ b/src/serena/dashboard.py @@ -2,7 +2,7 @@ import os import socket import threading from collections.abc import Callable -from datetime import datetime +from datetime import UTC, datetime from pathlib import Path from typing import TYPE_CHECKING, Any, Self @@ -148,23 +148,23 @@ class SerenaDashboardAPI: """ Get the installation date ID (YYYYMMDD format) based on the creation time of the SERENA_HOME directory. - + :return: Installation date as an integer in YYYYMMDD format """ serena_home = SerenaPaths().serena_user_home_dir - + # If SERENA_HOME doesn't exist yet, return today's date if not os.path.exists(serena_home): - today = datetime.now() + today = datetime.now(tz=UTC) return int(today.strftime("%Y%m%d")) - + # Get the creation/modification time of the SERENA_HOME directory stat_info = os.stat(serena_home) # Use st_ctime on Unix-like systems (change time, closest to creation time) # or st_mtime if ctime is not reliable creation_timestamp = stat_info.st_ctime - creation_date = datetime.fromtimestamp(creation_timestamp) - + creation_date = datetime.fromtimestamp(creation_timestamp, tz=UTC) + # Return as YYYYMMDD integer return int(creation_date.strftime("%Y%m%d")) @@ -350,12 +350,12 @@ class SerenaDashboardAPI: def _get_unread_news_ids() -> list[int]: all_news_files = (Path(SERENA_DASHBOARD_DIR) / "news").glob("*.html") all_news_ids = [int(f.stem) for f in all_news_files] - + # Filter news items by installation date installation_date_id = self._get_installation_date_id() # Only include news items published on or after the installation date all_news_ids = [news_id for news_id in all_news_ids if news_id >= installation_date_id] - + news_snippet_id_file = SerenaPaths().news_snippet_id_file if not os.path.exists(news_snippet_id_file): return all_news_ids diff --git a/test/serena/test_dashboard.py b/test/serena/test_dashboard.py index 5637b3e4..6b073793 100644 --- a/test/serena/test_dashboard.py +++ b/test/serena/test_dashboard.py @@ -8,8 +8,6 @@ from datetime import datetime from pathlib import Path from unittest.mock import MagicMock, patch -import pytest - from serena.dashboard import SerenaDashboardAPI @@ -30,7 +28,7 @@ class TestNewsDisplayLogic: # Should return a valid YYYYMMDD format integer assert isinstance(result, int) assert 20000101 <= result <= 99991231 # Valid date range - + # Should match today's or recent date (since we just created the directory) result_str = str(result) assert len(result_str) == 8