Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cthulahoops
Copy link
Owner

@cthulahoops cthulahoops commented Oct 6, 2025

  • Fix timezone warnings in tests.
  • Close discarded coroutines in update queue.

Summary by CodeRabbit

  • New Features
    • Timestamps are now consistently timezone-aware (UTC), improving accuracy in displays and logs.
  • Bug Fixes
    • Reduced runtime warnings and potential resource leaks by properly cleaning up discarded asynchronous tasks.
  • Tests
    • Updated test coverage to validate timezone-aware timestamp handling.

@coderabbitai
Copy link

coderabbitai bot commented Oct 6, 2025

Walkthrough

The change makes internal timestamps timezone-aware (UTC) in pets/agency.py and updates tests accordingly. It also updates pets/update_queues.py to close discarded coroutines during deduplication to avoid warnings, without altering public APIs.

Changes

Cohort / File(s) Summary of Changes
Timezone-aware datetime handling
pets/agency.py, tests/test_pets.py
Converted naive UTC datetimes to timezone-aware UTC: parse_dt now returns aware datetimes; Agency initializes with timezone-aware now; tests use timezone.utc and fromtimestamp for aware timestamps.
Coroutine cleanup in update deduplication
pets/update_queues.py
In deduplicated_updates, added logic to close discarded coroutines (e.g., updates[:-1]) via close() where available, both in None-trailing and general paths, preventing un-awaited coroutine warnings.

Pre-merge checks and finishing touches

✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pytest_warnings

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 355f1c2 and 17205be.

📒 Files selected for processing (3)
  • pets/agency.py (2 hunks)
  • pets/update_queues.py (1 hunks)
  • tests/test_pets.py (2 hunks)
🔇 Additional comments (4)
pets/agency.py (2)

16-16: LGTM! Timezone-aware datetime fixes the warning.

The addition of tzinfo=datetime.timezone.utc makes the parsed datetime timezone-aware, which is the correct approach to fix naive datetime warnings.


40-40: LGTM! Consistent with parse_dt changes.

Using datetime.datetime.now(datetime.timezone.utc) instead of the deprecated utcnow() makes the timestamp timezone-aware and aligns with the updated parse_dt function.

pets/update_queues.py (1)

59-62: LGTM! Properly closes discarded coroutines.

The logic correctly closes all but the last update in both code paths (shutdown and normal deduplication). The hasattr(update, 'close') check is a good safety measure. This prevents RuntimeWarnings about unawaited coroutines while maintaining the deduplication behavior.

Also applies to: 68-71

tests/test_pets.py (1)

4-4: LGTM! Test timestamps now timezone-aware.

The import of timezone and the switch from utcfromtimestamp (deprecated in Python 3.12+) to fromtimestamp(..., timezone.utc) correctly makes test timestamps timezone-aware, aligning with the changes in pets/agency.py.

Also applies to: 171-173


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cthulahoops cthulahoops merged commit b1c3c3d into main Oct 7, 2025
1 of 2 checks passed
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