Skip to content

Enforcing DocDetails.tzinfo to be UTC#1094

Merged
jamesbraza merged 1 commit intomainfrom
fixing-tzinfo-mismatch
Sep 19, 2025
Merged

Enforcing DocDetails.tzinfo to be UTC#1094
jamesbraza merged 1 commit intomainfrom
fixing-tzinfo-mismatch

Conversation

@jamesbraza
Copy link
Copy Markdown
Collaborator

Seen in client code:

Traceback (most recent call last):
  ...
    result = sum(doc_details_to_combine)
  File "/layers/google.python.pip/pip/lib/python3.13/site-packages/paperqa/types.py", line 1058, in __add__
    PREFER_OTHER = self.publication_date <= other.publication_date
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: can't compare offset-naive and offset-aware datetimes

This PR resolves this issue by ensuring all publication_date are in UTC

@jamesbraza jamesbraza self-assigned this Sep 19, 2025
Copilot AI review requested due to automatic review settings September 19, 2025 20:46
@jamesbraza jamesbraza added the bug Something isn't working label Sep 19, 2025
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Sep 19, 2025
Copy link
Copy Markdown
Contributor

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 resolves a TypeError that occurs when comparing offset-naive and offset-aware datetimes by enforcing all DocDetails.publication_date fields to be in UTC timezone.

  • Added a field validator to DocDetails class that ensures all publication dates are converted to UTC
  • Updated test data to use UTC-aware datetime objects
  • Added UTC import to necessary files

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/paperqa/types.py Added field validator to convert publication_date to UTC and imported UTC
tests/test_clients.py Updated test datetime objects to use UTC timezone and imported UTC

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

@dosubot
Copy link
Copy Markdown

dosubot bot commented Sep 19, 2025

Related Documentation

Checked 1 published document(s). No updates required.

How did I do? Any feedback?  Join Discord

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 19, 2025
@jamesbraza jamesbraza merged commit f775dc5 into main Sep 19, 2025
6 checks passed
@jamesbraza jamesbraza deleted the fixing-tzinfo-mismatch branch September 19, 2025 21:15
@dosubot
Copy link
Copy Markdown

dosubot bot commented Sep 19, 2025

Documentation Updates

Checked 1 published document(s). No updates required.

How did I do? Any feedback?  Join Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants