Skip to content

Support reflected timedelta addition for Time - #1045

Open
FanWu-ai wants to merge 1 commit into
python-pendulum:masterfrom
FanWu-ai:fix-time-reflected-addition-20261012
Open

FanWu-ai wants to merge 1 commit into
python-pendulum:masterfrom
FanWu-ai:fix-time-reflected-addition-20261012

Conversation

@FanWu-ai

Copy link
Copy Markdown
Contributor

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

Fix

pendulum.time(12, 30) + timedelta(minutes=15) succeeds, but reversing the operands raises TypeError. Add Time.__radd__ delegating to self.__add__, as DateTime already 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:

  • Fresh complete baseline: 1,871 passed / 3 existing skips in each pure-Python and native mode.
  • Final source and installed-wheel complete suites: 1,882 passed / 3 existing skips in each mode.
  • Exact final tests replayed on pristine source: 9 failures / 14 controls per backend.
  • Strict mypy (228 files), all hooks including Rust formatting/Clippy, strict MkDocs, rebuilt release wheel/sdist and strict Twine pass.
  • Artifact production-source bytes match; native imports verified. Independent complete reruns and 3,015 additional cases per backend pass.

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.

Delegate reversed addition through Time.__add__, preserving supported duration handling and subclass dispatch. Document both operand orders and add regressions.

AI assistance: OpenAI Codex.
@FanWu-ai
FanWu-ai marked this pull request as ready for review October 11, 2026 22:16
@codspeed

codspeed Bot commented Oct 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

ℹ️ 1 benchmark has no flame graph

The flamegraph could not be generated because we failed to resolve the symbols in the profiling trace. This happens when we fail to harvest information about language frames.

✅ 1 untouched benchmark


Comparing FanWu-ai:fix-time-reflected-addition-20261012 (3a2b77a) with master (7840d47)

Open in CodSpeed

This branch has not been deployed

No deployments
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.

1 participant