Skip to content

Conversation

@GitTimeraider
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings October 6, 2025 16:19
@GitTimeraider GitTimeraider merged commit 56d2a40 into main Oct 6, 2025
3 of 4 checks passed
Copy link

Copilot AI left a comment

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 addresses timezone compatibility issues in the currency exchange rate system by introducing a helper function to ensure datetime objects are timezone-aware before performing time calculations.

  • Added ensure_timezone_aware() helper function to handle naive datetime objects
  • Updated age calculation logic to use timezone-aware datetimes consistently
  • Applied timezone fixes to both primary and fallback provider cache age calculations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

ERAPI_URL = "https://open.er-api.com/v6/latest/EUR"


def ensure_timezone_aware(dt, default_tz=timezone.utc):
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

The function parameter dt should be documented with its expected type in the docstring for better API clarity.

Copilot uses AI. Check for mistakes.
"""
Ensure a datetime object is timezone-aware.
If naive, assume it's in the default timezone (UTC by default).
"""
Copy link

Copilot AI Oct 6, 2025

Choose a reason for hiding this comment

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

Missing input validation for the dt parameter. The function should handle cases where dt is None or not a datetime object to prevent AttributeError.

Suggested change
"""
"""
if dt is None:
raise ValueError("dt cannot be None")
if not isinstance(dt, datetime):
raise TypeError(f"dt must be a datetime object, got {type(dt).__name__}")

Copilot uses AI. Check for mistakes.
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