Skip to content

Include dates inside inverted intervals - #1065

Open
FanWu-ai wants to merge 1 commit into
python-pendulum:masterfrom
FanWu-ai:fix/inverted-interval-membership
Open

FanWu-ai wants to merge 1 commit into
python-pendulum:masterfrom
FanWu-ai:fix/inverted-interval-membership

Conversation

@FanWu-ai

Copy link
Copy Markdown
Contributor

Summary

An inverted interval iterates backwards, but its membership check always uses start <= item <= end. As a result, every member of Interval(Date(2024, 1, 3), Date(2024, 1, 1)), including its endpoints, is reported absent.

Choose the inclusive bounds according to endpoint order without changing the stored endpoints or iteration direction. Tests cover normal/inverted and absolute intervals; stdlib dates/aware datetimes and Pendulum inputs; zero-length intervals; and differently-offset datetime endpoints. The docs now explicitly describe inclusive, direction-independent membership.

Verification

Linux x86_64 / CPython 3.12.14, upstream e06dacedc4cdea90fa1286b3965d180ab94cf251:

  • Pristine full suite: 1,871 passed, 3 skipped with both pure-Python and newly built native Rust backends.
  • Final regression tests against pristine source: 5 failed, 16 passed.
  • Fixed full suite: 1,892 passed, 3 skipped with each backend (21 new regression/control cases).
  • Full Mypy: passed across 229 files.
  • prek run --all-files: all six hooks passed, including Ruff and Rust formatting/clippy.
  • mkdocs build --strict -f docs/mkdocs.yml: passed; the same six pre-existing informational anchor notices appear on the pristine build.
  • git diff --check: passed.
  • Additional independent checks: 2,000 randomized membership checks passed.

The unchanged skips are one Windows-only test and two existing unsupported zoneinfo POSIX-transition cases. Native-extension loading was verified. Other operating systems and Python versions were not tested locally. Hosted CI is not claimed passed.

Pull Request Check List

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

Prepared and tested with OpenAI Codex assistance, including automated review. No human review is claimed.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 20, 2026 21:38
@codspeed

codspeed Bot commented Oct 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

ℹ️ 1 benchmark has no flamegraph

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/inverted-interval-membership (8882e94) with master (e06dace)

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