Skip to content

Respect Python operator fallback for unsupported Duration operands - #30

Open
rupayon123 wants to merge 1 commit into
bolsote:masterfrom
rupayon123:contribution/operator-notimplemented-20260922
Open

rupayon123 wants to merge 1 commit into
bolsote:masterfrom
rupayon123:contribution/operator-notimplemented-20260922

Conversation

@rupayon123

Copy link
Copy Markdown

Fixes #24. Duration's comparison/arithmetic methods raise NotImplementedError for unsupported operands, preventing Python from using the other operand's reflected method. Return NotImplemented instead. Unrelated equality now returns false, custom reflected operations can participate, and unsupported arithmetic raises the standard TypeError. Existing datetime arithmetic is unchanged.

All six regression cases fail before the fix. Afterward, all 382 tests pass, with 100% reported source/branch coverage in a separate coverage run. Scoped Black/Flake8, strict source mypy, and git diff --check pass on Python 3.12.13. The __sub__ return annotation uses Any rather than incorrectly claiming None, retaining compatibility with the project's Python 3.7 minimum instead of importing newer types.NotImplementedType at runtime.

Prepared with AI assistance; Python operator fallback and existing datetime cases were verified.

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.

Duration __eq__ method should not raise NotImplementedError

1 participant