ics-py / ics-py

Pythonic and easy iCalendar library (rfc5545)

Home Page:http://icspy.readthedocs.org/en/stable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(Typing for) Event.end should allow None

Dr-Irv opened this issue · comments

If I have an Event that has begin and end set to valid times, and I clone that event, and then want to modify the times by moving it to a different day, then it is impossible to change the time of the event because of the checks about begin < start. So the only way to do it is to first set end to None, and then you can change begin, and then end

That's all fine, but the Visual Studio Code type checker (pyright) then complains that end cannot be set to None. So the types for Event.end() should use Optional as a possible argument type around ArrowLike and Arrow

commented

You are very right, we should change this as:

  1. As you said, it's inconvenient
  2. The RFC 5545 says that it is valid for a VEVENT to have a start but no duration or end.

For cases where a "VEVENT" calendar component
specifies a "DTSTART" property with a DATE value type but no
"DTEND" nor "DURATION" property, the event's duration is taken to
be one day. For cases where a "VEVENT" calendar component
specifies a "DTSTART" property with a DATE-TIME value type but no
"DTEND" property, the event ends on the same calendar date and
time of day specified by the "DTSTART" property.