Skip to content

Fix deadline check#377

Merged
S1ro1 merged 1 commit into
mainfrom
fix-deadline-2
Nov 30, 2025
Merged

Fix deadline check#377
S1ro1 merged 1 commit into
mainfrom
fix-deadline-2

Conversation

@S1ro1

@S1ro1 S1ro1 commented Nov 30, 2025

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings November 30, 2025 09:27
@S1ro1 S1ro1 merged commit fbed4bb into main Nov 30, 2025
6 of 9 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a timezone-related bug in the deadline check functionality by making the current time timezone-aware (UTC). The change ensures correct comparison between the current time and database-stored deadlines, which are timezone-aware datetime objects returned by PostgreSQL.

  • Changed import from from datetime import datetime to import datetime for better namespace clarity
  • Updated check_deadline() to use datetime.datetime.now(datetime.timezone.utc) instead of naive datetime.now()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


def check_deadline(leaderboard: LeaderboardItem):
now = datetime.now()
now = datetime.datetime.now(datetime.timezone.utc)

Copilot AI Nov 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests in test_check_deadline() use naive datetime objects (datetime.datetime.now() without timezone), but the production code now uses timezone-aware datetime objects (datetime.datetime.now(datetime.timezone.utc)). This mismatch means the tests are not accurately testing the actual behavior.

The tests should be updated to use timezone-aware datetime objects to match the production code:

def test_check_deadline():
    # Test valid deadline (future)
    future_deadline: LeaderboardItem = {
        "deadline": datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1),
        "name": "test",
    }
    submission.check_deadline(future_deadline)  # Should not raise

    # Test expired deadline
    past_deadline: LeaderboardItem = {
        "deadline": datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=1),
        "name": "test",
    }
    # ...

Additionally, the mock in mock_backend fixture (line 30) should also use timezone-aware datetime.

Copilot uses AI. Check for mistakes.
SinatrasC pushed a commit to SinatrasC/kernelbot that referenced this pull request Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants