fix: replace deprecated datetime.utcnow() with timezone-aware datetime.now(timezone.utc)#6581
fix: replace deprecated datetime.utcnow() with timezone-aware datetime.now(timezone.utc)#6581fazalpsinfo-cmyk wants to merge 2 commits into
Conversation
…e.now(timezone.utc) Replaced all instances of deprecated datetime.utcnow() with datetime.now(timezone.utc) across 4 memory module files. Affected files: - lib/crewai/src/crewai/memory/unified_memory.py - lib/crewai/src/crewai/memory/storage/lancedb_storage.py - lib/crewai/src/crewai/memory/types.py - lib/crewai/src/crewai/memory/encoding_flow.py
📝 WalkthroughWalkthroughMemory timestamp creation, parsing, storage, update flows, and recency calculations now use timezone-aware UTC datetimes. ChangesMemory timestamp consistency
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/crewai/src/crewai/memory/storage/lancedb_storage.py (1)
264-271: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winNormalize legacy timestamps to UTC in LanceDB records.
\_parse_dt()leaves naivedatetime.utcnow().isoformat()values unchanged, socompute_composite_score()andget_scope_info()can raiseTypeErrorwhen they mix naive and UTC-aware datetimes. Normalize both parsed strings anddatetimeinputs here, and reuse the same helper inget_scope_info().🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/crewai/src/crewai/memory/storage/lancedb_storage.py` around lines 264 - 271, Update _row_to_record’s _parse_dt helper to convert naive datetime inputs and parsed timestamp strings to UTC-aware datetimes, while preserving existing timezone information for aware values. Reuse this normalization helper in get_scope_info() so all timestamp comparisons in compute_composite_score() and scope handling consistently use UTC-aware datetimes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@lib/crewai/src/crewai/memory/storage/lancedb_storage.py`:
- Around line 264-271: Update _row_to_record’s _parse_dt helper to convert naive
datetime inputs and parsed timestamp strings to UTC-aware datetimes, while
preserving existing timezone information for aware values. Reuse this
normalization helper in get_scope_info() so all timestamp comparisons in
compute_composite_score() and scope handling consistently use UTC-aware
datetimes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 95a68663-00c3-4daf-939d-04ec76055510
📒 Files selected for processing (4)
lib/crewai/src/crewai/memory/encoding_flow.pylib/crewai/src/crewai/memory/storage/lancedb_storage.pylib/crewai/src/crewai/memory/types.pylib/crewai/src/crewai/memory/unified_memory.py
Replace deprecated
datetime.utcnow()withdatetime.now(timezone.utc)across the memory module for Python 3.12+ compatibility.datetime.utcnow()is deprecated since Python 3.12 (PEP 623).Files changed:
Support this work: https://buymeacoffee.com/muhamedfazalps