Skip to content

fix: select --sort-key on date properties crashed - #99

Merged
tobixen merged 5 commits into
masterfrom
fix-sort-key-dates-65
Nov 25, 2026
Merged

tobixen merged 5 commits into
masterfrom
fix-sort-key-dates-65

Conversation

@tobixen

@tobixen tobixen commented Nov 25, 2026

Copy link
Copy Markdown
Member

Fixes #65

Commit message:

fix: select --sort-key on date properties crashed

A plain property sort key returned the raw icalendar value, so DUE,
DTSTART and the like (vDDDTypes, which has no ordering) crashed the
sort with a TypeError, as did a property missing on some items.  Dates
and timestamps are now compared as timezone-aware timestamps, and items
without the property come last, also in a reversed sort.  DTSTART, DUE,
DTEND and DURATION come from the icalendar helper properties, so a task
with DTSTART and DURATION sorts on the DUE they give.

https://github.com/pycalendar/plann/issues/65

Prompt: [pick from the task list: "Fix select --sort-key on date
  properties (vDDDTypes TypeError)"]
Followup-Prompt: consider to use (sic) the helper properties in the
  icalendar library ... `.start`, `.end` and `.duration` rather than
  messing with `.dt`.

Assisted-By: Claude Opus 5.5
Reviewed-by: Tobias Brox <tobias@redpill-linpro.com>

🤖 Generated with Claude Code

With filterwarnings = error, an installed pytest-asyncio turns its own
deprecation warning (asyncio_default_fixture_loop_scope unset) into an
INTERNALERROR before any test runs.  plann has no async tests.

I finally decided to uninstall the system-wide pytest-asyncio - I can't
add "-p no:asyncio" to every project where I'd like to run tests.  It's
still considered harmless, and serves to mark that plann is (so far) not
supporting async operation, so I leave it in place here.

Prompt: fix "-p no:asyncio" in pyproject.toml, like it's done in several
  other projects

Assisted-By: Claude Opus 5.5
Reviewed-by: Tobias Brox <tobias@redpill-linpro.com>
dateparser returns pytz zones when a timezone is configured, and its
own pytz look-alike StaticTzInfo for an explicit UTC offset.
recurring_ical_events took StaticTzInfo for pytz and crashed calling
normalize() on it, so `plann select --start 2026-11-21T05:00+01:00`
failed on recurring events.  parse_dt now swaps such zones for a
zoneinfo zone or a fixed offset, keeping the wall clock.

niccokunzmann/python-recurring-ical-events#311

Prompts:
> Look into
> niccokunzmann/python-recurring-ical-events#311 (comment)
> - am I using the wrong libraries for handling timezones in plann?

> This sounds like an upstream problem with dateparser?  But yes, please
> implement [converting dateparser's tzinfo to zoneinfo or a
> fixed offset in parse_dt]. (...)

Assisted-By: Claude Opus 5.5
Reviewed-by: Tobias Brox <tobias@redpill-linpro.com>
The plan from check-for-panic --interactive-fix-timeline (also run by
interactive manage-tasks) listed start and end per task, so moving a
task meant editing both.  It now lists start and duration, all in one
timezone named at the top of the file, and offers to plan again after
pinning.  A line that cannot be parsed reopens the editor instead of
crashing and losing the edit.

Prompts:
> read tmp-sticking and consider something [a note: the plan editor
> is hard to use; one should be able to edit the start and keep the
> duration, and to rerun it easily, also from manage-tasks]

> Reconsidering ... "delete the end" should not be needed.  Editing
> the start should suffice to get the end auto-adjusted.  The file
> format needs to make it obvious it works this way.  About time
> zones, make sure all timestamps are in the same time zone and add
> information about the timezone at the top of the file.

Assisted-By: Claude Opus 5.5
Reviewed-by: Tobias Brox <tobias@redpill-linpro.com>
#97

The plan from check-for-panic --interactive-fix-timeline (also run by
interactive manage-tasks) lists start and duration instead of start and
end, all in one timezone named at the top, and an unparsable line
reopens the editor; it offers to plan again after pinning.  Also
piggy-backs a test-config fix disabling a system-wide pytest-asyncio.

Commits:
- 91c635b test: disable a system-wide pytest-asyncio
- 5d422ef feat: start+duration in the pin-tasks editor plan

Assisted-By: Claude Opus 5.5
Reviewed-by: Tobias Brox <tobias@redpill-linpro.com>
A plain property sort key returned the raw icalendar value, so DUE,
DTSTART and the like (vDDDTypes, which has no ordering) crashed the
sort with a TypeError, as did a property missing on some items.  Dates
and timestamps are now compared as timezone-aware timestamps, and items
without the property come last, also in a reversed sort.  DTSTART, DUE,
DTEND and DURATION come from the icalendar helper properties, so a task
with DTSTART and DURATION sorts on the DUE they give.

#65

Prompt: [pick from the task list: "Fix select --sort-key on date
  properties (vDDDTypes TypeError)"]
Followup-Prompt: consider to use (sic) the helper properties in the
  icalendar library ... `.start`, `.end` and `.duration` rather than
  messing with `.dt`.

Assisted-By: Claude Opus 5.5
Reviewed-by: Tobias Brox <tobias@redpill-linpro.com>
@tobixen
tobixen force-pushed the fix-sort-key-dates-65 branch from 256a992 to 78d4db1 Compare November 25, 2026 07:33
@tobixen
tobixen merged commit 78d4db1 into master Nov 25, 2026
9 checks passed
@tobixen
tobixen deleted the fix-sort-key-dates-65 branch November 25, 2026 09:22
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.

select --sort-key DUE crashes with TypeError on vDDDTypes

1 participant