Repository navigation
Conversation
Delegate reversed addition through Time.__add__, preserving supported duration handling and subclass dispatch. Document both operand orders and add regressions. AI assistance: OpenAI Codex.
Merging this PR will not alter performance
|
Wkhanex
left a comment
There was a problem hiding this comment.
The reflected-addition delegation preserves the existing Time arithmetic behavior in my checks of 3a2b77a. I compared 2,000 seeded times and sub-day timedeltas against datetime.combine(...)+timedelta, including midnight rollover and microsecond carries; all matched. A subclass overriding __add__ was dispatched correctly when the timedelta was on the left. I also confirmed that a negative one-microsecond timedelta (normalized with a nonzero days field) and a whole-day timedelta retain the existing TypeError restriction. The time-addition module passed 23 tests on Python 3.12 in pure-Python mode. I have not run the full suite or native backend.
Review and local validation prepared with OpenAI Codex assistance.
Pull Request Check List
Fix
pendulum.time(12, 30) + timedelta(minutes=15)succeeds, but reversing the operands raisesTypeError. AddTime.__radd__delegating toself.__add__, asDateTimealready does. This preserves subclass dispatch and the existing handling of zero, microseconds, midnight rollover, unsupported types and day-containing durations.Eleven new cases cover native timedelta/Pendulum Duration, carry and rollover, rejected day components, exact result type and subclass overrides. Documentation shows both operand orders and the existing day restriction.
Validation
Linux/Python 3.12.14, unchanged project dependencies and pinned hooks:
The unchanged skips cover Windows-only behavior and upstream timezone-transition limits. Strict docs retain existing INFO-level anchor diagnostics; packaging retains an existing Cargo metadata warning. Other Python/OS combinations and hosted CI are not claimed passed.
Prepared and tested with AI assistance (OpenAI Codex); no human review is claimed.