From 82ca1b8491d76dd76def0b74b823ebee36e89bfe Mon Sep 17 00:00:00 2001 From: Sashank Bhamidi Date: Sun, 22 Nov 2026 18:19:16 +0530 Subject: [PATCH 1/7] add failing tests for RFC 9073 and RFC 9074 completion --- .../tests/events/rfc_9073_order_parameter.ics | 8 + .../tests/events/rfc_9073_participant.ics | 17 ++ .../tests/events/rfc_9073_vlocation.ics | 12 ++ .../tests/events/rfc_9073_vresource.ics | 11 + src/icalendar/tests/test_rfc_9073.py | 198 ++++++++++++++++++ 5 files changed, 246 insertions(+) create mode 100644 src/icalendar/tests/events/rfc_9073_order_parameter.ics create mode 100644 src/icalendar/tests/events/rfc_9073_participant.ics create mode 100644 src/icalendar/tests/events/rfc_9073_vlocation.ics create mode 100644 src/icalendar/tests/events/rfc_9073_vresource.ics create mode 100644 src/icalendar/tests/test_rfc_9073.py diff --git a/src/icalendar/tests/events/rfc_9073_order_parameter.ics b/src/icalendar/tests/events/rfc_9073_order_parameter.ics new file mode 100644 index 000000000..7e484fff5 --- /dev/null +++ b/src/icalendar/tests/events/rfc_9073_order_parameter.ics @@ -0,0 +1,8 @@ +BEGIN:VEVENT +SUMMARY:Things That Need Ordering (Unlike This Meeting) +DTSTART:20261121T090000Z +DTEND:20261121T100000Z +UID:rfc9073-order-test@example.com +CATEGORIES;ORDER=1:Coffee +CATEGORIES;ORDER=2:Agenda +END:VEVENT diff --git a/src/icalendar/tests/events/rfc_9073_participant.ics b/src/icalendar/tests/events/rfc_9073_participant.ics new file mode 100644 index 000000000..16025f795 --- /dev/null +++ b/src/icalendar/tests/events/rfc_9073_participant.ics @@ -0,0 +1,17 @@ +BEGIN:VEVENT +SUMMARY:How to Parse Your Own Calendar Invite (and Why It Hurts) +DTSTART:20261115T140000Z +DTEND:20261115T150000Z +UID:rfc9073-participant-test@example.com +BEGIN:PARTICIPANT +PARTICIPANT-TYPE:ACTIVE +CALENDAR-ADDRESS:mailto:guido@pycon.example.com +UID:rfc9073-participant-uid@example.com +SUMMARY:Guido van Rossum Memorial Keynote Stand-In +BEGIN:VLOCATION +UID:rfc9073-vlocation-in-participant@example.com +NAME:Main Stage (The Big One) +LOCATION-TYPE:arena +END:VLOCATION +END:PARTICIPANT +END:VEVENT diff --git a/src/icalendar/tests/events/rfc_9073_vlocation.ics b/src/icalendar/tests/events/rfc_9073_vlocation.ics new file mode 100644 index 000000000..dfde9e1f3 --- /dev/null +++ b/src/icalendar/tests/events/rfc_9073_vlocation.ics @@ -0,0 +1,12 @@ +BEGIN:VEVENT +SUMMARY:Astronomical Society Night: We Finally Looked Up +DTSTART:20261121T210000Z +DTEND:20261121T230000Z +UID:rfc9073-vlocation-test@example.com +BEGIN:VLOCATION +UID:rfc9073-vlocation-uid@example.com +NAME:Hydrogen Line Hackerspace Observatory +LOCATION-TYPE:office +GEO:40.4168;-3.7038 +END:VLOCATION +END:VEVENT diff --git a/src/icalendar/tests/events/rfc_9073_vresource.ics b/src/icalendar/tests/events/rfc_9073_vresource.ics new file mode 100644 index 000000000..f32a1d1f7 --- /dev/null +++ b/src/icalendar/tests/events/rfc_9073_vresource.ics @@ -0,0 +1,11 @@ +BEGIN:VEVENT +SUMMARY:RFC Reading Group: 9073 Is Actually Interesting +DTSTART:20261121T160000Z +DTEND:20261121T170000Z +UID:rfc9073-vresource-test@example.com +BEGIN:VRESOURCE +UID:rfc9073-vresource-uid@example.com +NAME:The Sentient Projector (It Knows When You Click Past Its Slide) +RESOURCE-TYPE:PROJECTOR +END:VRESOURCE +END:VEVENT diff --git a/src/icalendar/tests/test_rfc_9073.py b/src/icalendar/tests/test_rfc_9073.py new file mode 100644 index 000000000..faeb04b85 --- /dev/null +++ b/src/icalendar/tests/test_rfc_9073.py @@ -0,0 +1,198 @@ +"""Test RFC 9073 Event Publishing Extensions to iCalendar. + +See https://www.rfc-editor.org/rfc/rfc9073 +and also https://github.com/PyCalendar/icalendar/issues/656 +""" + +import pytest + +from icalendar import ( + PARTICIPANT_TYPE, + PROXIMITY, + RELTYPE, + RESOURCE_TYPE, + Participant, + VLocation, + VResource, + vCalAddress, + vText, + vUri, +) + + +@pytest.mark.parametrize( + "name", + [ + "PARTICIPANT_TYPE", + "RESOURCE_TYPE", + "PROXIMITY", + "Participant", + "VLocation", + "VResource", + ], +) +def test_public_names_importable(name): + """All RFC 9073 public names are importable from the top-level package.""" + import icalendar + + assert hasattr(icalendar, name) + + +def test_reltype_snooze(): + """RELTYPE.SNOOZE is defined per :rfc:`9074#section-7.1`.""" + assert RELTYPE.SNOOZE == "SNOOZE" + + +@pytest.mark.parametrize( + ("prop_cls", "value"), + [ + (vCalAddress, "mailto:speaker@example.com"), + (vUri, "https://example.com/cal"), + ], +) +def test_order_parameter_on_prop_types(prop_cls, value): + """ORDER parameter is accessible on multi-instance property types per :rfc:`9073#section-5.1`.""" + prop = prop_cls(value) + prop.ORDER = 1 + assert prop.ORDER == 1 + + +@pytest.mark.parametrize( + ("prop_cls", "value"), + [ + (vCalAddress, "mailto:speaker@example.com"), + (vUri, "https://example.com/cal"), + ], +) +def test_derived_parameter_on_prop_types(prop_cls, value): + """DERIVED parameter is accessible on multi-instance property types per :rfc:`9073#section-5.3`.""" + prop = prop_cls(value) + prop.DERIVED = True + assert prop.DERIVED is True + + +def test_order_validation(): + """ORDER parameter rejects values less than 1 per :rfc:`9073#section-5.1`.""" + t = vText("test") + with pytest.raises((ValueError, TypeError)): + t.ORDER = 0 + + +def test_event_participants_accessor(events): + """Event.participants returns typed Participant instances per :rfc:`9073#section-7.1`.""" + event = events.rfc_9073_participant + assert len(event.participants) == 1 + assert isinstance(event.participants[0], Participant) + + +def test_event_locations_accessor(events): + """Event.locations returns typed VLocation instances per :rfc:`9073#section-7.2`.""" + event = events.rfc_9073_vlocation + assert len(event.locations) == 1 + assert isinstance(event.locations[0], VLocation) + + +def test_event_resources_accessor(events): + """Event.resources returns typed VResource instances per :rfc:`9073#section-7.3`.""" + event = events.rfc_9073_vresource + assert len(event.resources) == 1 + assert isinstance(event.resources[0], VResource) + + +def test_participant_type_accessor(events): + """Participant.participant_type returns PARTICIPANT_TYPE enum per :rfc:`9073#section-6.2`.""" + p = events.rfc_9073_participant.participants[0] + assert p.participant_type == PARTICIPANT_TYPE.ACTIVE + + +def test_participant_calendar_address(events): + """Participant.calendar_address returns vCalAddress per :rfc:`9073#section-6.4`.""" + p = events.rfc_9073_participant.participants[0] + assert isinstance(p.calendar_address, vCalAddress) + assert "guido@pycon.example.com" in str(p.calendar_address) + + +def test_vlocation_in_participant(events): + """VLOCATION nested inside PARTICIPANT is parsed per :rfc:`9073#section-7.1`.""" + p = events.rfc_9073_participant.participants[0] + assert len(p.locations) == 1 + assert isinstance(p.locations[0], VLocation) + + +def test_vlocation_name_accessor(events): + """VLocation.location_name returns the NAME property per :rfc:`9073#section-7.2`.""" + loc = events.rfc_9073_vlocation.locations[0] + assert loc.location_name == "Hydrogen Line Hackerspace Observatory" + + +def test_vresource_resource_type(events): + """VResource.resource_type returns RESOURCE_TYPE enum per :rfc:`9073#section-7.3`.""" + res = events.rfc_9073_vresource.resources[0] + assert res.resource_type == RESOURCE_TYPE.PROJECTOR + + +def test_alarm_proximity_typed(events): + """Alarm.proximity returns PROXIMITY enum per :rfc:`9074#section-8.1`.""" + alarm = events.rfc_9074_example_proximity.subcomponents[0] + assert alarm.proximity == PROXIMITY.DEPART + + +def test_vlocation_in_alarm_registered(events): + """VLOCATION inside VALARM parses as a VLocation instance per :rfc:`9074#section-8`.""" + alarm = events.rfc_9074_example_proximity.subcomponents[0] + assert isinstance(alarm.subcomponents[0], VLocation) + + +def test_order_round_trip(events): + """ORDER parameter round-trips through parse and serialize per :rfc:`9073#section-5.1`.""" + from icalendar import Calendar + + event = events.rfc_9073_order_parameter + cal = Calendar() + cal.add_component(event) + reparsed = Calendar.from_ical(cal.to_ical()) + revent = reparsed.events[0] + cats = revent.get("CATEGORIES") + if isinstance(cats, list): + orders = [int(c.params.get("ORDER", 0)) for c in cats] + else: + orders = [int(cats.params.get("ORDER", 0))] if cats else [] + assert 1 in orders + assert 2 in orders + + +def test_derived_round_trip(): + """DERIVED parameter round-trips through parse and serialize per :rfc:`9073#section-5.3`.""" + from icalendar import Calendar, Event + + event = Event() + addr = vCalAddress("mailto:speaker@example.com") + addr.DERIVED = True + event.add("ATTENDEE", addr) + cal = Calendar() + cal.add_component(event) + reparsed = Calendar.from_ical(cal.to_ical()) + attendee = reparsed.events[0].get("ATTENDEE") + assert attendee.params.get("DERIVED") == "TRUE" + + +def test_participant_type_enum_values(): + """PARTICIPANT_TYPE enum has all IANA-registered values from :rfc:`9073#section-11.2.1`.""" + assert PARTICIPANT_TYPE.ACTIVE == "ACTIVE" + assert PARTICIPANT_TYPE.INACTIVE == "INACTIVE" + assert PARTICIPANT_TYPE.SPONSOR == "SPONSOR" + assert PARTICIPANT_TYPE.CONTACT == "CONTACT" + assert PARTICIPANT_TYPE.BOOKING_CONTACT == "BOOKING-CONTACT" + assert PARTICIPANT_TYPE.EMERGENCY_CONTACT == "EMERGENCY-CONTACT" + assert PARTICIPANT_TYPE.PUBLICITY_CONTACT == "PUBLICITY-CONTACT" + assert PARTICIPANT_TYPE.PLANNER_CONTACT == "PLANNER-CONTACT" + assert PARTICIPANT_TYPE.PERFORMER == "PERFORMER" + assert PARTICIPANT_TYPE.SPEAKER == "SPEAKER" + + +def test_resource_type_enum_values(): + """RESOURCE_TYPE enum has all IANA-registered values from :rfc:`9073#section-11.2.2`.""" + assert RESOURCE_TYPE.ROOM == "ROOM" + assert RESOURCE_TYPE.PROJECTOR == "PROJECTOR" + assert RESOURCE_TYPE.REMOTE_CONFERENCE_AUDIO == "REMOTE-CONFERENCE-AUDIO" + assert RESOURCE_TYPE.REMOTE_CONFERENCE_VIDEO == "REMOTE-CONFERENCE-VIDEO" From 193baa75367fd692492e5de15040b2de23c5da29 Mon Sep 17 00:00:00 2001 From: Sashank Bhamidi Date: Sun, 22 Nov 2026 18:22:31 +0530 Subject: [PATCH 2/7] add RFC 9073 Event Publishing Extensions and complete RFC 9074 --- .../api/icalendar.cal.participant.rst | 8 ++ docs/reference/api/icalendar.cal.rst | 3 + .../reference/api/icalendar.cal.vlocation.rst | 8 ++ .../reference/api/icalendar.cal.vresource.rst | 8 ++ news/656.feature.1 | 1 + news/656.feature.2 | 1 + news/656.feature.3 | 1 + news/657.feature.1 | 1 + src/icalendar/__init__.py | 12 +++ src/icalendar/alarms.py | 9 ++ src/icalendar/attr/__init__.py | 9 +- src/icalendar/cal/__init__.py | 6 ++ src/icalendar/cal/alarm.py | 17 ++++ src/icalendar/cal/component_factory.py | 6 ++ src/icalendar/cal/event.py | 21 +++++ src/icalendar/cal/free_busy.py | 21 +++++ src/icalendar/cal/journal.py | 21 +++++ src/icalendar/cal/participant.py | 91 +++++++++++++++++++ src/icalendar/cal/todo.py | 21 +++++ src/icalendar/cal/vlocation.py | 74 +++++++++++++++ src/icalendar/cal/vresource.py | 80 ++++++++++++++++ src/icalendar/enums.py | 79 ++++++++++++++++ src/icalendar/param.py | 64 +++++++++++++ src/icalendar/prop/cal_address.py | 2 + src/icalendar/prop/factory.py | 9 ++ src/icalendar/prop/text.py | 2 +- src/icalendar/prop/uri.py | 12 ++- 27 files changed, 581 insertions(+), 6 deletions(-) create mode 100644 docs/reference/api/icalendar.cal.participant.rst create mode 100644 docs/reference/api/icalendar.cal.vlocation.rst create mode 100644 docs/reference/api/icalendar.cal.vresource.rst create mode 100644 news/656.feature.1 create mode 100644 news/656.feature.2 create mode 100644 news/656.feature.3 create mode 100644 news/657.feature.1 create mode 100644 src/icalendar/cal/participant.py create mode 100644 src/icalendar/cal/vlocation.py create mode 100644 src/icalendar/cal/vresource.py diff --git a/docs/reference/api/icalendar.cal.participant.rst b/docs/reference/api/icalendar.cal.participant.rst new file mode 100644 index 000000000..4fb7857ee --- /dev/null +++ b/docs/reference/api/icalendar.cal.participant.rst @@ -0,0 +1,8 @@ +icalendar.cal.participant module +================================ + +.. automodule:: icalendar.cal.participant + :ignore-module-all: + :members: + :show-inheritance: + :undoc-members: diff --git a/docs/reference/api/icalendar.cal.rst b/docs/reference/api/icalendar.cal.rst index 66ebb2837..5b6506059 100644 --- a/docs/reference/api/icalendar.cal.rst +++ b/docs/reference/api/icalendar.cal.rst @@ -18,8 +18,11 @@ Submodules icalendar.cal.free_busy icalendar.cal.journal icalendar.cal.lazy + icalendar.cal.participant icalendar.cal.timezone icalendar.cal.todo + icalendar.cal.vlocation + icalendar.cal.vresource Module contents --------------- diff --git a/docs/reference/api/icalendar.cal.vlocation.rst b/docs/reference/api/icalendar.cal.vlocation.rst new file mode 100644 index 000000000..8770e939b --- /dev/null +++ b/docs/reference/api/icalendar.cal.vlocation.rst @@ -0,0 +1,8 @@ +icalendar.cal.vlocation module +============================== + +.. automodule:: icalendar.cal.vlocation + :ignore-module-all: + :members: + :show-inheritance: + :undoc-members: diff --git a/docs/reference/api/icalendar.cal.vresource.rst b/docs/reference/api/icalendar.cal.vresource.rst new file mode 100644 index 000000000..e8ce06b3b --- /dev/null +++ b/docs/reference/api/icalendar.cal.vresource.rst @@ -0,0 +1,8 @@ +icalendar.cal.vresource module +============================== + +.. automodule:: icalendar.cal.vresource + :ignore-module-all: + :members: + :show-inheritance: + :undoc-members: diff --git a/news/656.feature.1 b/news/656.feature.1 new file mode 100644 index 000000000..556f0b762 --- /dev/null +++ b/news/656.feature.1 @@ -0,0 +1 @@ +Add PARTICIPANT, VLOCATION, and VRESOURCE components from :rfc:`9073`. @SashankBhamidi diff --git a/news/656.feature.2 b/news/656.feature.2 new file mode 100644 index 000000000..8023d9270 --- /dev/null +++ b/news/656.feature.2 @@ -0,0 +1 @@ +Add ORDER, SCHEMA, and DERIVED property parameters from :rfc:`9073`. @SashankBhamidi diff --git a/news/656.feature.3 b/news/656.feature.3 new file mode 100644 index 000000000..aff1810c8 --- /dev/null +++ b/news/656.feature.3 @@ -0,0 +1 @@ +Add PARTICIPANT-TYPE, RESOURCE-TYPE, LOCATION-TYPE, CALENDAR-ADDRESS, STYLED-DESCRIPTION, and STRUCTURED-DATA properties from :rfc:`9073`. @SashankBhamidi diff --git a/news/657.feature.1 b/news/657.feature.1 new file mode 100644 index 000000000..9aff29740 --- /dev/null +++ b/news/657.feature.1 @@ -0,0 +1 @@ +Complete :rfc:`9074` support: add PROXIMITY enum, typed Alarm.proximity accessor, RELTYPE.SNOOZE, and register VLOCATION inside VALARM. @SashankBhamidi diff --git a/src/icalendar/__init__.py b/src/icalendar/__init__.py index 1684a0e07..c8d7b7648 100644 --- a/src/icalendar/__init__.py +++ b/src/icalendar/__init__.py @@ -13,10 +13,13 @@ FreeBusy, Journal, LazyCalendar, + Participant, Timezone, TimezoneDaylight, TimezoneStandard, Todo, + VLocation, + VResource, ) from icalendar.enums import ( ACTION, @@ -24,10 +27,13 @@ CLASS, CUTYPE, FBTYPE, + PARTICIPANT_TYPE, PARTSTAT, + PROXIMITY, RANGE, RELATED, RELTYPE, + RESOURCE_TYPE, ROLE, STATUS, TRANSP, @@ -109,10 +115,13 @@ "CLASS", "CUTYPE", "FBTYPE", + "PARTICIPANT_TYPE", "PARTSTAT", + "PROXIMITY", "RANGE", "RELATED", "RELTYPE", + "RESOURCE_TYPE", "ROLE", "STATUS", "TRANSP", @@ -147,11 +156,14 @@ "LocalTimezoneMissing", "NFields", "Parameters", + "Participant", "Timezone", "TimezoneDaylight", "TimezoneStandard", "Todo", "TypesFactory", + "VLocation", + "VResource", "XCalParsingError", "__version__", "__version_tuple__", diff --git a/src/icalendar/alarms.py b/src/icalendar/alarms.py index 75bfb1d0a..a3677c060 100644 --- a/src/icalendar/alarms.py +++ b/src/icalendar/alarms.py @@ -141,6 +141,15 @@ def attachments(self) -> list[vUri | vBinary]: """ return self.alarm.attachments + @property + def proximity(self): + """The type of location-based trigger for this alarm. + + This delegates to :attr:`Alarm.proximity + `. + """ + return self.alarm.proximity + @property def parent(self) -> Parent | None: """The component that contains the alarm. diff --git a/src/icalendar/attr/__init__.py b/src/icalendar/attr/__init__.py index f55042b7c..079520342 100644 --- a/src/icalendar/attr/__init__.py +++ b/src/icalendar/attr/__init__.py @@ -1327,17 +1327,18 @@ def _del_organizer(self: Component): def single_string_enum_property( name: str, enum: type[StrEnum], - default: StrEnum | str, + default: StrEnum | str | None, docs: str, preserve_unknown: bool = False, ) -> property: """Create a property to access a single string value and convert it to an enum.""" - prop = single_string_property(name, docs, default=default) + _str_default = "" if default is None else default + prop = single_string_property(name, docs, default=_str_default) - def fget(self: Component) -> StrEnum | str: + def fget(self: Component) -> StrEnum | str | None: """Get the value.""" value = prop.fget(self) - if value == default: + if value == _str_default: return default try: return enum(str(value)) diff --git a/src/icalendar/cal/__init__.py b/src/icalendar/cal/__init__.py index 0a8279344..326556e11 100644 --- a/src/icalendar/cal/__init__.py +++ b/src/icalendar/cal/__init__.py @@ -14,8 +14,11 @@ from .free_busy import FreeBusy from .journal import Journal from .lazy import LazyCalendar +from .participant import Participant from .timezone import Timezone, TimezoneDaylight, TimezoneStandard from .todo import Todo +from .vlocation import VLocation +from .vresource import VResource __all__ = [ "Alarm", @@ -28,8 +31,11 @@ "FreeBusy", "Journal", "LazyCalendar", + "Participant", "Timezone", "TimezoneDaylight", "TimezoneStandard", "Todo", + "VLocation", + "VResource", ] diff --git a/src/icalendar/cal/alarm.py b/src/icalendar/cal/alarm.py index 9349dcd49..0a635bff2 100644 --- a/src/icalendar/cal/alarm.py +++ b/src/icalendar/cal/alarm.py @@ -30,6 +30,7 @@ from icalendar.cal.component import Component from icalendar.cal.examples import get_example from icalendar.enums import ACTION as AlarmAction # noqa: N811 +from icalendar.enums import PROXIMITY from icalendar.error import InvalidCalendar from icalendar.prop import vCalAddress @@ -204,6 +205,22 @@ class Alarm(Component): """, ) + proximity = single_string_enum_property( + "PROXIMITY", + PROXIMITY, + None, + """The type of location-based trigger for this alarm per :rfc:`9074#section-8.1`. + + When set, a VLOCATION sub-component MUST also be present to identify + the location that triggers the alarm. + + Returns a :class:`~icalendar.enums.PROXIMITY` member for known values + (``ARRIVE``, ``DEPART``, ``CONNECT``, ``DISCONNECT``), a plain + :class:`str` for unknown values, or ``None`` when absent. + """, + preserve_unknown=True, + ) + TRIGGER = create_single_property( "TRIGGER", "dt", diff --git a/src/icalendar/cal/component_factory.py b/src/icalendar/cal/component_factory.py index 78d726e43..719588aed 100644 --- a/src/icalendar/cal/component_factory.py +++ b/src/icalendar/cal/component_factory.py @@ -51,12 +51,15 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: from icalendar.cal.event import Event from icalendar.cal.free_busy import FreeBusy from icalendar.cal.journal import Journal + from icalendar.cal.participant import Participant from icalendar.cal.timezone import ( Timezone, TimezoneDaylight, TimezoneStandard, ) from icalendar.cal.todo import Todo + from icalendar.cal.vlocation import VLocation + from icalendar.cal.vresource import VResource self.add_component_class(Calendar) self.add_component_class(Event) @@ -69,6 +72,9 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.add_component_class(Alarm) self.add_component_class(Available) self.add_component_class(Availability) + self.add_component_class(Participant) + self.add_component_class(VLocation) + self.add_component_class(VResource) def add_component_class(self, cls: type[Component]) -> None: """Add a component class to the factory. diff --git a/src/icalendar/cal/event.py b/src/icalendar/cal/event.py index 31f823827..d376b975e 100644 --- a/src/icalendar/cal/event.py +++ b/src/icalendar/cal/event.py @@ -260,6 +260,27 @@ class Event(Component): ) ignore_exceptions = True + @property + def participants(self): + """All PARTICIPANT sub-components of this event per :rfc:`9073#section-7.1`.""" + from icalendar.cal.participant import Participant + + return self.walk(Participant.name) + + @property + def locations(self): + """All VLOCATION sub-components of this event per :rfc:`9073#section-7.2`.""" + from icalendar.cal.vlocation import VLocation + + return self.walk(VLocation.name) + + @property + def resources(self): + """All VRESOURCE sub-components of this event per :rfc:`9073#section-7.3`.""" + from icalendar.cal.vresource import VResource + + return self.walk(VResource.name) + @property def alarms(self) -> Alarms: """Compute the alarm times for this component. diff --git a/src/icalendar/cal/free_busy.py b/src/icalendar/cal/free_busy.py index a0f2ab560..b25e288c0 100644 --- a/src/icalendar/cal/free_busy.py +++ b/src/icalendar/cal/free_busy.py @@ -182,6 +182,27 @@ def new( cls._validate_start_and_end(start, end) return free_busy + @property + def participants(self): + """All PARTICIPANT sub-components of this component per :rfc:`9073#section-7.1`.""" + from icalendar.cal.participant import Participant + + return self.walk(Participant.name) + + @property + def locations(self): + """All VLOCATION sub-components of this component per :rfc:`9073#section-7.2`.""" + from icalendar.cal.vlocation import VLocation + + return self.walk(VLocation.name) + + @property + def resources(self): + """All VRESOURCE sub-components of this component per :rfc:`9073#section-7.3`.""" + from icalendar.cal.vresource import VResource + + return self.walk(VResource.name) + @classmethod def example(cls, name: str = "example") -> FreeBusy: """Return the FreeBusy example with the given name.""" diff --git a/src/icalendar/cal/journal.py b/src/icalendar/cal/journal.py index 72ecec9d1..b93744b15 100644 --- a/src/icalendar/cal/journal.py +++ b/src/icalendar/cal/journal.py @@ -303,6 +303,27 @@ def new( return journal + @property + def participants(self): + """All PARTICIPANT sub-components of this journal per :rfc:`9073#section-7.1`.""" + from icalendar.cal.participant import Participant + + return self.walk(Participant.name) + + @property + def locations(self): + """All VLOCATION sub-components of this journal per :rfc:`9073#section-7.2`.""" + from icalendar.cal.vlocation import VLocation + + return self.walk(VLocation.name) + + @property + def resources(self): + """All VRESOURCE sub-components of this journal per :rfc:`9073#section-7.3`.""" + from icalendar.cal.vresource import VResource + + return self.walk(VResource.name) + @classmethod def example(cls, name: str = "example") -> Journal: """Return the journal example with the given name.""" diff --git a/src/icalendar/cal/participant.py b/src/icalendar/cal/participant.py new file mode 100644 index 000000000..047af570c --- /dev/null +++ b/src/icalendar/cal/participant.py @@ -0,0 +1,91 @@ +""":rfc:`9073` PARTICIPANT component.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +from icalendar.attr import ( + description_property, + single_string_enum_property, + summary_property, + uid_property, +) +from icalendar.cal.component import Component +from icalendar.enums import PARTICIPANT_TYPE + +if TYPE_CHECKING: + from icalendar.prop import vCalAddress + + +class Participant(Component): + """A PARTICIPANT calendar component from :rfc:`9073#section-7.1`. + + Provides structured participant information for a calendar component. + May appear inside VEVENT, VTODO, VJOURNAL, or VFREEBUSY. + Multiple instances are allowed. PARTICIPANT-TYPE is required. + + Example: + + .. code-block:: pycon + + >>> from icalendar import Participant, PARTICIPANT_TYPE + >>> p = Participant() + >>> p.participant_type = PARTICIPANT_TYPE.ACTIVE + >>> p.participant_type + + """ + + name = "PARTICIPANT" + singletons = ( + "PARTICIPANT-TYPE", + "CALENDAR-ADDRESS", + "DESCRIPTION", + "SUMMARY", + "UID", + ) + required = ("PARTICIPANT-TYPE",) + + participant_type = single_string_enum_property( + "PARTICIPANT-TYPE", + PARTICIPANT_TYPE, + None, + """The type of participant per :rfc:`9073#section-6.2`. + + This property MUST appear exactly once in a PARTICIPANT component. + Returns a :class:`~icalendar.enums.PARTICIPANT_TYPE` member for + IANA-registered values, a plain :class:`str` for unknown values, + or ``None`` when absent. + + IANA-registered values from :rfc:`9073#section-11.2.1`: + ``ACTIVE``, ``INACTIVE``, ``SPONSOR``, ``CONTACT``, + ``BOOKING-CONTACT``, ``EMERGENCY-CONTACT``, ``PUBLICITY-CONTACT``, + ``PLANNER-CONTACT``, ``PERFORMER``, ``SPEAKER``. + """, + preserve_unknown=True, + ) + + @property + def calendar_address(self) -> vCalAddress | None: + """The scheduling address for this participant per :rfc:`9073#section-6.4`. + + Returns a :class:`~icalendar.prop.cal_address.vCalAddress` instance + or ``None`` when no CALENDAR-ADDRESS property is present. + """ + return self.get("CALENDAR-ADDRESS") + + uid = uid_property + summary = summary_property + description = description_property + + @property + def locations(self) -> list: + """All VLOCATION sub-components of this participant per :rfc:`9073#section-7.2`.""" + return self.walk("VLOCATION") + + @property + def resources(self) -> list: + """All VRESOURCE sub-components of this participant per :rfc:`9073#section-7.3`.""" + return self.walk("VRESOURCE") + + +__all__ = ["Participant"] diff --git a/src/icalendar/cal/todo.py b/src/icalendar/cal/todo.py index 64fd73c41..804084b4c 100644 --- a/src/icalendar/cal/todo.py +++ b/src/icalendar/cal/todo.py @@ -304,6 +304,27 @@ def set_end( X_MOZ_SNOOZE_TIME = X_MOZ_SNOOZE_TIME_property X_MOZ_LASTACK = X_MOZ_LASTACK_property + @property + def participants(self): + """All PARTICIPANT sub-components of this to-do per :rfc:`9073#section-7.1`.""" + from icalendar.cal.participant import Participant + + return self.walk(Participant.name) + + @property + def locations(self): + """All VLOCATION sub-components of this to-do per :rfc:`9073#section-7.2`.""" + from icalendar.cal.vlocation import VLocation + + return self.walk(VLocation.name) + + @property + def resources(self): + """All VRESOURCE sub-components of this to-do per :rfc:`9073#section-7.3`.""" + from icalendar.cal.vresource import VResource + + return self.walk(VResource.name) + @property def alarms(self) -> Alarms: """Compute the alarm times for this component. diff --git a/src/icalendar/cal/vlocation.py b/src/icalendar/cal/vlocation.py new file mode 100644 index 000000000..2442bbd75 --- /dev/null +++ b/src/icalendar/cal/vlocation.py @@ -0,0 +1,74 @@ +""":rfc:`9073` VLOCATION component.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +from icalendar.attr import ( + description_property, + single_string_property, + uid_property, +) +from icalendar.cal.component import Component + +if TYPE_CHECKING: + from icalendar.prop import vGeo + + +class VLocation(Component): + """A VLOCATION calendar component from :rfc:`9073#section-7.2`. + + Provides structured location information for a calendar component. + May appear inside VEVENT, VTODO, VJOURNAL, VFREEBUSY, PARTICIPANT, + or VALARM (per :rfc:`9074#section-8`). Multiple instances are allowed. + + Example: + + .. code-block:: pycon + + >>> from icalendar import VLocation + >>> loc = VLocation() + >>> loc.location_name = "Conference Room A" + >>> loc.uid = "room-a-uid@example.com" + >>> str(loc.location_name) + 'Conference Room A' + """ + + name = "VLOCATION" + singletons = ("NAME", "DESCRIPTION", "GEO", "LOCATION-TYPE", "UID") + + location_name = single_string_property( + "NAME", + """The display name of this location per :rfc:`7986#section-5.1`. + + Returns the empty string when no NAME property is set. + """, + ) + + description = description_property + + uid = uid_property + + location_type = single_string_property( + "LOCATION-TYPE", + """The raw LOCATION-TYPE value per :rfc:`9073#section-6.1`. + + The property value is a comma-separated list of location type tokens + from the IANA registry defined in :rfc:`4589#section-3` + (e.g. ``"office,airport"``). This accessor returns the raw string; + split on commas to work with individual tokens. Returns the empty + string when not set. + """, + ) + + @property + def geo(self) -> vGeo | None: + """The geographic position of this location per :rfc:`5545#section-3.8.1.6`. + + Returns a :class:`~icalendar.prop.geo.vGeo` instance or ``None`` when + no GEO property is set. + """ + return self.get("GEO") + + +__all__ = ["VLocation"] diff --git a/src/icalendar/cal/vresource.py b/src/icalendar/cal/vresource.py new file mode 100644 index 000000000..d2378d025 --- /dev/null +++ b/src/icalendar/cal/vresource.py @@ -0,0 +1,80 @@ +""":rfc:`9073` VRESOURCE component.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +from icalendar.attr import ( + description_property, + single_string_enum_property, + single_string_property, + uid_property, +) +from icalendar.cal.component import Component +from icalendar.enums import RESOURCE_TYPE + +if TYPE_CHECKING: + from icalendar.prop import vGeo + + +class VResource(Component): + """A VRESOURCE calendar component from :rfc:`9073#section-7.3`. + + Provides structured resource information for a calendar component. + May appear inside VEVENT, VTODO, VJOURNAL, VFREEBUSY, or PARTICIPANT. + Multiple instances are allowed. + + Example: + + .. code-block:: pycon + + >>> from icalendar import VResource, RESOURCE_TYPE + >>> res = VResource() + >>> res.resource_name = "Projector" + >>> res.resource_type = RESOURCE_TYPE.PROJECTOR + >>> res.resource_type + + """ + + name = "VRESOURCE" + singletons = ("NAME", "DESCRIPTION", "GEO", "RESOURCE-TYPE", "UID") + + resource_name = single_string_property( + "NAME", + """The display name of this resource per :rfc:`7986#section-5.1`. + + Returns the empty string when no NAME property is set. + """, + ) + + description = description_property + + uid = uid_property + + resource_type = single_string_enum_property( + "RESOURCE-TYPE", + RESOURCE_TYPE, + None, + """The type of resource per :rfc:`9073#section-6.3`. + + Returns a :class:`~icalendar.enums.RESOURCE_TYPE` member for IANA-registered + values, a plain :class:`str` for unknown values, or ``None`` when absent. + + IANA-registered values are defined in :rfc:`9073#section-11.2.2`: + ``ROOM``, ``PROJECTOR``, ``REMOTE-CONFERENCE-AUDIO``, + ``REMOTE-CONFERENCE-VIDEO``. + """, + preserve_unknown=True, + ) + + @property + def geo(self) -> vGeo | None: + """The geographic position of this resource per :rfc:`5545#section-3.8.1.6`. + + Returns a :class:`~icalendar.prop.geo.vGeo` instance or ``None`` when + no GEO property is set. + """ + return self.get("GEO") + + +__all__ = ["VResource"] diff --git a/src/icalendar/enums.py b/src/icalendar/enums.py index 1e0701920..a5a36011e 100644 --- a/src/icalendar/enums.py +++ b/src/icalendar/enums.py @@ -364,6 +364,7 @@ class RELTYPE(StrEnum): DEPENDS_ON = "DEPENDS-ON" REFID = "REFID" CONCEPT = "CONCEPT" + SNOOZE = "SNOOZE" class RANGE(StrEnum): @@ -578,16 +579,94 @@ class TRANSP(StrEnum): TRANSPARENT = "TRANSPARENT" +class PARTICIPANT_TYPE(StrEnum): # noqa: N801 + """Enum for PARTICIPANT-TYPE from :rfc:`9073#section-6.2`. + + Identifies the type of participant represented by a PARTICIPANT + component. IANA-registered values are listed in :rfc:`9073#section-11.2.1`. + Unknown values are allowed (IANA-extensible). + + Possible values are the following. + + - :attr:`ACTIVE` + - :attr:`INACTIVE` + - :attr:`SPONSOR` + - :attr:`CONTACT` + - :attr:`BOOKING_CONTACT` + - :attr:`EMERGENCY_CONTACT` + - :attr:`PUBLICITY_CONTACT` + - :attr:`PLANNER_CONTACT` + - :attr:`PERFORMER` + - :attr:`SPEAKER` + """ + + ACTIVE = "ACTIVE" + INACTIVE = "INACTIVE" + SPONSOR = "SPONSOR" + CONTACT = "CONTACT" + BOOKING_CONTACT = "BOOKING-CONTACT" + EMERGENCY_CONTACT = "EMERGENCY-CONTACT" + PUBLICITY_CONTACT = "PUBLICITY-CONTACT" + PLANNER_CONTACT = "PLANNER-CONTACT" + PERFORMER = "PERFORMER" + SPEAKER = "SPEAKER" + + +class RESOURCE_TYPE(StrEnum): # noqa: N801 + """Enum for RESOURCE-TYPE from :rfc:`9073#section-6.3`. + + Identifies the type of resource represented by a VRESOURCE component. + IANA-registered values are listed in :rfc:`9073#section-11.2.2`. + Unknown values are allowed (IANA-extensible). + + Possible values are the following. + + - :attr:`ROOM` + - :attr:`PROJECTOR` + - :attr:`REMOTE_CONFERENCE_AUDIO` + - :attr:`REMOTE_CONFERENCE_VIDEO` + """ + + ROOM = "ROOM" + PROJECTOR = "PROJECTOR" + REMOTE_CONFERENCE_AUDIO = "REMOTE-CONFERENCE-AUDIO" + REMOTE_CONFERENCE_VIDEO = "REMOTE-CONFERENCE-VIDEO" + + +class PROXIMITY(StrEnum): + """Enum for PROXIMITY from :rfc:`9074#section-8.1`. + + Specifies the type of location-based trigger for a + :class:`~icalendar.cal.alarm.Alarm` component. When set, a VLOCATION + sub-component MUST be present to define the location. + + Possible values are the following. + + - :attr:`ARRIVE` + - :attr:`DEPART` + - :attr:`CONNECT` + - :attr:`DISCONNECT` + """ + + ARRIVE = "ARRIVE" + DEPART = "DEPART" + CONNECT = "CONNECT" + DISCONNECT = "DISCONNECT" + + __all__ = [ "ACTION", "BUSYTYPE", "CLASS", "CUTYPE", "FBTYPE", + "PARTICIPANT_TYPE", "PARTSTAT", + "PROXIMITY", "RANGE", "RELATED", "RELTYPE", + "RESOURCE_TYPE", "ROLE", "STATUS", "TRANSP", diff --git a/src/icalendar/param.py b/src/icalendar/param.py index bca86330f..a21b7afd6 100644 --- a/src/icalendar/param.py +++ b/src/icalendar/param.py @@ -838,12 +838,74 @@ def _del_GAP(prop): # noqa: N802 GAP = property(_get_GAP, _set_GAP, _del_GAP) + +def _convert_order_read(value: str) -> int: + """Convert ORDER string to int on read.""" + return int(value) + + +def _convert_order_write(value) -> str: + """Validate and convert ORDER to string for storage.""" + result = int(value) + if result < 1: + raise ValueError(f"ORDER must be a positive integer >= 1, got {result}") + return str(result) + + +ORDER = string_parameter( + "ORDER", + """Indicate the relative ordering of a property amongst multiple properties +of the same type. + +Conformance: + This property parameter is specified in :rfc:`9073#section-5.1`. + + This parameter MAY be specified on any property that permits multiple + instances in a single component. The value is a positive integer + starting at 1; absent means the property is unordered among those without + an ORDER value. No duplicate ORDER values are allowed within the same + property name on a component. +""", + convert=_convert_order_read, + convert_to=_convert_order_write, +) + +SCHEMA = string_parameter( + "SCHEMA", + """Identify the schema that a STRUCTURED-DATA value conforms to. + +Conformance: + This property parameter is specified in :rfc:`9073#section-5.2`. + + This parameter SHOULD be specified on the STRUCTURED-DATA property. + Its value is a URI identifying the schema the structured data + follows. It supplements the media type given by the FMTTYPE + parameter, which alone may not be specific enough to interpret the + value. +""", +) + +DERIVED = boolean_parameter("DERIVED", False) +"""Indicate that a property's value is derived from other property values. + +Conformance: + This property parameter is specified in :rfc:`9073#section-5.3`. + + This parameter MAY be specified on any property whose value can be + derived from the value of one or more other properties. When set to + ``TRUE``, clients MUST NOT update the property's value directly, since + it is expected to be recomputed from the properties it derives from. + The default, when absent, is ``FALSE``. +""" + + __all__ = [ "ALTREP", "CN", "CUTYPE", "DELEGATED_FROM", "DELEGATED_TO", + "DERIVED", "DIR", "EMAIL", "FBTYPE", @@ -853,11 +915,13 @@ def _del_GAP(prop): # noqa: N802 "LANGUAGE", "LINKREL", "MEMBER", + "ORDER", "PARTSTAT", "RANGE", "RELATED", "ROLE", "RSVP", + "SCHEMA", "SENT_BY", "TZID", "VALUE", diff --git a/src/icalendar/prop/cal_address.py b/src/icalendar/prop/cal_address.py index 1a1260915..112d7abe6 100644 --- a/src/icalendar/prop/cal_address.py +++ b/src/icalendar/prop/cal_address.py @@ -212,10 +212,12 @@ def has_email(self, email: str) -> bool: CUTYPE, DELEGATED_FROM, DELEGATED_TO, + DERIVED, DIR, EMAIL, LANGUAGE, MEMBER, + ORDER, PARTSTAT, ROLE, RSVP, diff --git a/src/icalendar/prop/factory.py b/src/icalendar/prop/factory.py index 20b73da44..eaf569f9f 100644 --- a/src/icalendar/prop/factory.py +++ b/src/icalendar/prop/factory.py @@ -187,6 +187,15 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: "exrule": "recur", "rdate": "date-time-list", "rrule": "recur", + # RFC 7986 properties + "name": "text", + # RFC 9073 properties + "location-type": "text", + "participant-type": "text", + "resource-type": "text", + "calendar-address": "cal-address", + "styled-description": "text", # full VALUE dispatch in future + "structured-data": "unknown", # full VALUE dispatch in future # Alarm Component Properties "action": "text", "repeat": "integer", diff --git a/src/icalendar/prop/text.py b/src/icalendar/prop/text.py index 28fc66b87..8daa7a1ab 100644 --- a/src/icalendar/prop/text.py +++ b/src/icalendar/prop/text.py @@ -173,7 +173,7 @@ def ical_value(self) -> str: """The string value of the text.""" return str(self) - from icalendar.param import ALTREP, GAP, LANGUAGE, RELTYPE, VALUE + from icalendar.param import ALTREP, DERIVED, GAP, LANGUAGE, ORDER, RELTYPE, VALUE def to_jcal(self, name: str) -> list: """The jCal representation of this property according to :rfc:`7265`.""" diff --git a/src/icalendar/prop/uri.py b/src/icalendar/prop/uri.py index 2f0fdd3c1..8c9cc3cb7 100644 --- a/src/icalendar/prop/uri.py +++ b/src/icalendar/prop/uri.py @@ -127,7 +127,17 @@ def __repr__(self) -> str: """repr(self)""" return f"{self.__class__.__name__}({self.uri!r})" - from icalendar.param import FMTTYPE, GAP, LABEL, LANGUAGE, LINKREL, RELTYPE, VALUE + from icalendar.param import ( + DERIVED, + FMTTYPE, + GAP, + LABEL, + LANGUAGE, + LINKREL, + ORDER, + RELTYPE, + VALUE, + ) def to_xcal(self, element: Element) -> None: """Add the xCal representation of this property according to :rfc:`6321`.""" From b2d18d81eec48d5d1b3cdf65ba9394df5c8ce05a Mon Sep 17 00:00:00 2001 From: Sashank Bhamidi Date: Tue, 24 Nov 2026 03:12:46 +0530 Subject: [PATCH 3/7] apply Steve's review: rename VLocation to Location, VResource to Resource, fix docstrings and enums --- docs/reference/api/icalendar.cal.location.rst | 8 ++++ docs/reference/api/icalendar.cal.resource.rst | 8 ++++ docs/reference/api/icalendar.cal.rst | 4 +- .../reference/api/icalendar.cal.vlocation.rst | 8 ---- .../reference/api/icalendar.cal.vresource.rst | 8 ---- news/656.feature.1 | 2 +- news/656.feature.2 | 2 +- news/656.feature.3 | 2 +- news/657.feature.1 | 2 +- src/icalendar/__init__.py | 8 ++-- src/icalendar/cal/__init__.py | 8 ++-- src/icalendar/cal/alarm.py | 12 +++-- src/icalendar/cal/component_factory.py | 8 ++-- src/icalendar/cal/event.py | 8 ++-- src/icalendar/cal/free_busy.py | 8 ++-- src/icalendar/cal/journal.py | 8 ++-- .../cal/{vlocation.py => location.py} | 43 +++++++++++------ src/icalendar/cal/participant.py | 21 +++++--- .../cal/{vresource.py => resource.py} | 40 ++++++++++------ src/icalendar/cal/todo.py | 8 ++-- src/icalendar/enums.py | 48 ++++++++++--------- src/icalendar/param.py | 41 ++++++++-------- src/icalendar/tests/test_rfc_9073.py | 34 ++++++------- 23 files changed, 185 insertions(+), 154 deletions(-) create mode 100644 docs/reference/api/icalendar.cal.location.rst create mode 100644 docs/reference/api/icalendar.cal.resource.rst delete mode 100644 docs/reference/api/icalendar.cal.vlocation.rst delete mode 100644 docs/reference/api/icalendar.cal.vresource.rst rename src/icalendar/cal/{vlocation.py => location.py} (52%) rename src/icalendar/cal/{vresource.py => resource.py} (57%) diff --git a/docs/reference/api/icalendar.cal.location.rst b/docs/reference/api/icalendar.cal.location.rst new file mode 100644 index 000000000..25f58ae8f --- /dev/null +++ b/docs/reference/api/icalendar.cal.location.rst @@ -0,0 +1,8 @@ +icalendar.cal.location module +============================= + +.. automodule:: icalendar.cal.location + :ignore-module-all: + :members: + :show-inheritance: + :undoc-members: diff --git a/docs/reference/api/icalendar.cal.resource.rst b/docs/reference/api/icalendar.cal.resource.rst new file mode 100644 index 000000000..010699351 --- /dev/null +++ b/docs/reference/api/icalendar.cal.resource.rst @@ -0,0 +1,8 @@ +icalendar.cal.resource module +============================= + +.. automodule:: icalendar.cal.resource + :ignore-module-all: + :members: + :show-inheritance: + :undoc-members: diff --git a/docs/reference/api/icalendar.cal.rst b/docs/reference/api/icalendar.cal.rst index 5b6506059..89d484e1e 100644 --- a/docs/reference/api/icalendar.cal.rst +++ b/docs/reference/api/icalendar.cal.rst @@ -18,11 +18,11 @@ Submodules icalendar.cal.free_busy icalendar.cal.journal icalendar.cal.lazy + icalendar.cal.location icalendar.cal.participant + icalendar.cal.resource icalendar.cal.timezone icalendar.cal.todo - icalendar.cal.vlocation - icalendar.cal.vresource Module contents --------------- diff --git a/docs/reference/api/icalendar.cal.vlocation.rst b/docs/reference/api/icalendar.cal.vlocation.rst deleted file mode 100644 index 8770e939b..000000000 --- a/docs/reference/api/icalendar.cal.vlocation.rst +++ /dev/null @@ -1,8 +0,0 @@ -icalendar.cal.vlocation module -============================== - -.. automodule:: icalendar.cal.vlocation - :ignore-module-all: - :members: - :show-inheritance: - :undoc-members: diff --git a/docs/reference/api/icalendar.cal.vresource.rst b/docs/reference/api/icalendar.cal.vresource.rst deleted file mode 100644 index e8ce06b3b..000000000 --- a/docs/reference/api/icalendar.cal.vresource.rst +++ /dev/null @@ -1,8 +0,0 @@ -icalendar.cal.vresource module -============================== - -.. automodule:: icalendar.cal.vresource - :ignore-module-all: - :members: - :show-inheritance: - :undoc-members: diff --git a/news/656.feature.1 b/news/656.feature.1 index 556f0b762..c8bfbd628 100644 --- a/news/656.feature.1 +++ b/news/656.feature.1 @@ -1 +1 @@ -Add PARTICIPANT, VLOCATION, and VRESOURCE components from :rfc:`9073`. @SashankBhamidi +Added :class:`~icalendar.cal.participant.Participant`, :class:`~icalendar.cal.location.Location`, and :class:`~icalendar.cal.resource.Resource` components from :rfc:`9073`. :user:`SashankBhamidi` diff --git a/news/656.feature.2 b/news/656.feature.2 index 8023d9270..e09dce0f5 100644 --- a/news/656.feature.2 +++ b/news/656.feature.2 @@ -1 +1 @@ -Add ORDER, SCHEMA, and DERIVED property parameters from :rfc:`9073`. @SashankBhamidi +Added ORDER, SCHEMA, and DERIVED property parameters from :rfc:`9073`. :user:`SashankBhamidi` diff --git a/news/656.feature.3 b/news/656.feature.3 index aff1810c8..f85cd8810 100644 --- a/news/656.feature.3 +++ b/news/656.feature.3 @@ -1 +1 @@ -Add PARTICIPANT-TYPE, RESOURCE-TYPE, LOCATION-TYPE, CALENDAR-ADDRESS, STYLED-DESCRIPTION, and STRUCTURED-DATA properties from :rfc:`9073`. @SashankBhamidi +Added PARTICIPANT-TYPE, RESOURCE-TYPE, LOCATION-TYPE, CALENDAR-ADDRESS, STYLED-DESCRIPTION, and STRUCTURED-DATA properties from :rfc:`9073`. :user:`SashankBhamidi` diff --git a/news/657.feature.1 b/news/657.feature.1 index 9aff29740..b35029231 100644 --- a/news/657.feature.1 +++ b/news/657.feature.1 @@ -1 +1 @@ -Complete :rfc:`9074` support: add PROXIMITY enum, typed Alarm.proximity accessor, RELTYPE.SNOOZE, and register VLOCATION inside VALARM. @SashankBhamidi +Completed :rfc:`9074` support: added PROXIMITY enum, typed Alarm.proximity accessor, RELTYPE.SNOOZE, and registered VLOCATION inside VALARM. :user:`SashankBhamidi` diff --git a/src/icalendar/__init__.py b/src/icalendar/__init__.py index c8d7b7648..1d80018ca 100644 --- a/src/icalendar/__init__.py +++ b/src/icalendar/__init__.py @@ -18,8 +18,8 @@ TimezoneDaylight, TimezoneStandard, Todo, - VLocation, - VResource, + Location, + Resource, ) from icalendar.enums import ( ACTION, @@ -162,8 +162,8 @@ "TimezoneStandard", "Todo", "TypesFactory", - "VLocation", - "VResource", + "Location", + "Resource", "XCalParsingError", "__version__", "__version_tuple__", diff --git a/src/icalendar/cal/__init__.py b/src/icalendar/cal/__init__.py index 326556e11..8d975c5bc 100644 --- a/src/icalendar/cal/__init__.py +++ b/src/icalendar/cal/__init__.py @@ -17,8 +17,8 @@ from .participant import Participant from .timezone import Timezone, TimezoneDaylight, TimezoneStandard from .todo import Todo -from .vlocation import VLocation -from .vresource import VResource +from .location import Location +from .resource import Resource __all__ = [ "Alarm", @@ -36,6 +36,6 @@ "TimezoneDaylight", "TimezoneStandard", "Todo", - "VLocation", - "VResource", + "Location", + "Resource", ] diff --git a/src/icalendar/cal/alarm.py b/src/icalendar/cal/alarm.py index bf94e84e8..be2fc3881 100644 --- a/src/icalendar/cal/alarm.py +++ b/src/icalendar/cal/alarm.py @@ -211,12 +211,14 @@ class Alarm(Component): None, """The type of location-based trigger for this alarm per :rfc:`9074#section-8.1`. - When set, a VLOCATION sub-component MUST also be present to identify - the location that triggers the alarm. + Although the RFC says that when this sub-component is set, a VLOCATION + sub-component MUST also be present to identify the location that + triggers the alarm, icalendar does not enforce this requirement. - Returns a :class:`~icalendar.enums.PROXIMITY` member for known values - (``ARRIVE``, ``DEPART``, ``CONNECT``, ``DISCONNECT``), a plain - :class:`str` for unknown values, or ``None`` when absent. + Returns: + Either a :class:`~icalendar.enums.PROXIMITY` member for known values + (``ARRIVE``, ``DEPART``, ``CONNECT``, or ``DISCONNECT``), a plain + :class:`str` for unknown values, or ``None`` when absent. """, preserve_unknown=True, ) diff --git a/src/icalendar/cal/component_factory.py b/src/icalendar/cal/component_factory.py index 1ddfb0410..911e152cf 100644 --- a/src/icalendar/cal/component_factory.py +++ b/src/icalendar/cal/component_factory.py @@ -59,8 +59,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: TimezoneStandard, ) from icalendar.cal.todo import Todo - from icalendar.cal.vlocation import VLocation - from icalendar.cal.vresource import VResource + from icalendar.cal.location import Location + from icalendar.cal.resource import Resource self.add_component_class(Calendar) self.add_component_class(Event) @@ -74,8 +74,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.add_component_class(Available) self.add_component_class(Availability) self.add_component_class(Participant) - self.add_component_class(VLocation) - self.add_component_class(VResource) + self.add_component_class(Location) + self.add_component_class(Resource) def add_component_class(self, cls: type[Component]) -> None: """Add a component class to the factory. diff --git a/src/icalendar/cal/event.py b/src/icalendar/cal/event.py index 4bef2bdff..21a77a4c5 100644 --- a/src/icalendar/cal/event.py +++ b/src/icalendar/cal/event.py @@ -270,16 +270,16 @@ def participants(self): @property def locations(self): """All VLOCATION sub-components of this event per :rfc:`9073#section-7.2`.""" - from icalendar.cal.vlocation import VLocation + from icalendar.cal.location import Location - return self.walk(VLocation.name) + return self.walk(Location.name) @property def resources(self): """All VRESOURCE sub-components of this event per :rfc:`9073#section-7.3`.""" - from icalendar.cal.vresource import VResource + from icalendar.cal.resource import Resource - return self.walk(VResource.name) + return self.walk(Resource.name) @property def alarms(self) -> Alarms: diff --git a/src/icalendar/cal/free_busy.py b/src/icalendar/cal/free_busy.py index b25e288c0..9b8f7cfe9 100644 --- a/src/icalendar/cal/free_busy.py +++ b/src/icalendar/cal/free_busy.py @@ -192,16 +192,16 @@ def participants(self): @property def locations(self): """All VLOCATION sub-components of this component per :rfc:`9073#section-7.2`.""" - from icalendar.cal.vlocation import VLocation + from icalendar.cal.location import Location - return self.walk(VLocation.name) + return self.walk(Location.name) @property def resources(self): """All VRESOURCE sub-components of this component per :rfc:`9073#section-7.3`.""" - from icalendar.cal.vresource import VResource + from icalendar.cal.resource import Resource - return self.walk(VResource.name) + return self.walk(Resource.name) @classmethod def example(cls, name: str = "example") -> FreeBusy: diff --git a/src/icalendar/cal/journal.py b/src/icalendar/cal/journal.py index b93744b15..af6b495b8 100644 --- a/src/icalendar/cal/journal.py +++ b/src/icalendar/cal/journal.py @@ -313,16 +313,16 @@ def participants(self): @property def locations(self): """All VLOCATION sub-components of this journal per :rfc:`9073#section-7.2`.""" - from icalendar.cal.vlocation import VLocation + from icalendar.cal.location import Location - return self.walk(VLocation.name) + return self.walk(Location.name) @property def resources(self): """All VRESOURCE sub-components of this journal per :rfc:`9073#section-7.3`.""" - from icalendar.cal.vresource import VResource + from icalendar.cal.resource import Resource - return self.walk(VResource.name) + return self.walk(Resource.name) @classmethod def example(cls, name: str = "example") -> Journal: diff --git a/src/icalendar/cal/vlocation.py b/src/icalendar/cal/location.py similarity index 52% rename from src/icalendar/cal/vlocation.py rename to src/icalendar/cal/location.py index 2442bbd75..1c77928f7 100644 --- a/src/icalendar/cal/vlocation.py +++ b/src/icalendar/cal/location.py @@ -1,4 +1,4 @@ -""":rfc:`9073` VLOCATION component.""" +""":rfc:`9073` Location component.""" from __future__ import annotations @@ -15,19 +15,26 @@ from icalendar.prop import vGeo -class VLocation(Component): +class Location(Component): """A VLOCATION calendar component from :rfc:`9073#section-7.2`. - Provides structured location information for a calendar component. - May appear inside VEVENT, VTODO, VJOURNAL, VFREEBUSY, PARTICIPANT, - or VALARM (per :rfc:`9074#section-8`). Multiple instances are allowed. + This component provides structured location information for a calendar + component. + + It may appear inside :class:`~icalendar.cal.alarm.Alarm`, + :class:`~icalendar.cal.event.Event`, + :class:`~icalendar.cal.free_busy.FreeBusy`, + :class:`~icalendar.cal.journal.Journal`, + :class:`~icalendar.cal.participant.Participant`, or + :class:`~icalendar.cal.todo.Todo` per :rfc:`9074#section-8`. Multiple + instances are allowed. Example: .. code-block:: pycon - >>> from icalendar import VLocation - >>> loc = VLocation() + >>> from icalendar import Location + >>> loc = Location() >>> loc.location_name = "Conference Room A" >>> loc.uid = "room-a-uid@example.com" >>> str(loc.location_name) @@ -41,7 +48,9 @@ class VLocation(Component): "NAME", """The display name of this location per :rfc:`7986#section-5.1`. - Returns the empty string when no NAME property is set. + Returns: + The value of the NAME property when set, or the empty string when + no NAME property is set. """, ) @@ -54,10 +63,13 @@ class VLocation(Component): """The raw LOCATION-TYPE value per :rfc:`9073#section-6.1`. The property value is a comma-separated list of location type tokens - from the IANA registry defined in :rfc:`4589#section-3` - (e.g. ``"office,airport"``). This accessor returns the raw string; - split on commas to work with individual tokens. Returns the empty - string when not set. + from the IANA registry defined in :rfc:`4589#section-3`, + for example, ``"office,airport"``. This accessor returns the raw + string. Split on commas to work with individual tokens. + + Returns: + The value of the LOCATION-TYPE property if set, or the empty string + when not set. """, ) @@ -65,10 +77,11 @@ class VLocation(Component): def geo(self) -> vGeo | None: """The geographic position of this location per :rfc:`5545#section-3.8.1.6`. - Returns a :class:`~icalendar.prop.geo.vGeo` instance or ``None`` when - no GEO property is set. + Returns: + A :class:`~icalendar.prop.geo.vGeo` instance, or ``None`` when + no GEO property is set. """ return self.get("GEO") -__all__ = ["VLocation"] +__all__ = ["Location"] diff --git a/src/icalendar/cal/participant.py b/src/icalendar/cal/participant.py index 047af570c..6b9827543 100644 --- a/src/icalendar/cal/participant.py +++ b/src/icalendar/cal/participant.py @@ -20,9 +20,12 @@ class Participant(Component): """A PARTICIPANT calendar component from :rfc:`9073#section-7.1`. - Provides structured participant information for a calendar component. - May appear inside VEVENT, VTODO, VJOURNAL, or VFREEBUSY. - Multiple instances are allowed. PARTICIPANT-TYPE is required. + This component provides structured participant information for a calendar + component. It may appear inside :class:`~icalendar.cal.event.Event`, + :class:`~icalendar.cal.free_busy.FreeBusy`, + :class:`~icalendar.cal.journal.Journal`, or + :class:`~icalendar.cal.todo.Todo` per :rfc:`9074#section-8`. Multiple + instances are allowed. Example: @@ -51,10 +54,10 @@ class Participant(Component): None, """The type of participant per :rfc:`9073#section-6.2`. - This property MUST appear exactly once in a PARTICIPANT component. Returns a :class:`~icalendar.enums.PARTICIPANT_TYPE` member for IANA-registered values, a plain :class:`str` for unknown values, - or ``None`` when absent. + or ``None`` when absent. icalendar does not enforce that this + property appears exactly once. IANA-registered values from :rfc:`9073#section-11.2.1`: ``ACTIVE``, ``INACTIVE``, ``SPONSOR``, ``CONTACT``, @@ -80,12 +83,16 @@ def calendar_address(self) -> vCalAddress | None: @property def locations(self) -> list: """All VLOCATION sub-components of this participant per :rfc:`9073#section-7.2`.""" - return self.walk("VLOCATION") + from icalendar.cal.location import Location + + return self.walk(Location.name) @property def resources(self) -> list: """All VRESOURCE sub-components of this participant per :rfc:`9073#section-7.3`.""" - return self.walk("VRESOURCE") + from icalendar.cal.resource import Resource + + return self.walk(Resource.name) __all__ = ["Participant"] diff --git a/src/icalendar/cal/vresource.py b/src/icalendar/cal/resource.py similarity index 57% rename from src/icalendar/cal/vresource.py rename to src/icalendar/cal/resource.py index d2378d025..cd8992282 100644 --- a/src/icalendar/cal/vresource.py +++ b/src/icalendar/cal/resource.py @@ -1,4 +1,4 @@ -""":rfc:`9073` VRESOURCE component.""" +""":rfc:`9073` Resource component.""" from __future__ import annotations @@ -17,19 +17,23 @@ from icalendar.prop import vGeo -class VResource(Component): +class Resource(Component): """A VRESOURCE calendar component from :rfc:`9073#section-7.3`. - Provides structured resource information for a calendar component. - May appear inside VEVENT, VTODO, VJOURNAL, VFREEBUSY, or PARTICIPANT. - Multiple instances are allowed. + This component provides structured resource information for a calendar + component. It may appear inside :class:`~icalendar.cal.event.Event`, + :class:`~icalendar.cal.free_busy.FreeBusy`, + :class:`~icalendar.cal.journal.Journal`, + :class:`~icalendar.cal.participant.Participant`, or + :class:`~icalendar.cal.todo.Todo` per :rfc:`9074#section-8`. Multiple + instances are allowed. Example: .. code-block:: pycon - >>> from icalendar import VResource, RESOURCE_TYPE - >>> res = VResource() + >>> from icalendar import Resource, RESOURCE_TYPE + >>> res = Resource() >>> res.resource_name = "Projector" >>> res.resource_type = RESOURCE_TYPE.PROJECTOR >>> res.resource_type @@ -43,7 +47,9 @@ class VResource(Component): "NAME", """The display name of this resource per :rfc:`7986#section-5.1`. - Returns the empty string when no NAME property is set. + Returns: + The value of the NAME property when set, or the empty string when + no NAME property is set. """, ) @@ -57,12 +63,15 @@ class VResource(Component): None, """The type of resource per :rfc:`9073#section-6.3`. - Returns a :class:`~icalendar.enums.RESOURCE_TYPE` member for IANA-registered - values, a plain :class:`str` for unknown values, or ``None`` when absent. - IANA-registered values are defined in :rfc:`9073#section-11.2.2`: - ``ROOM``, ``PROJECTOR``, ``REMOTE-CONFERENCE-AUDIO``, + ``ROOM``, ``PROJECTOR``, ``REMOTE-CONFERENCE-AUDIO``, and ``REMOTE-CONFERENCE-VIDEO``. + + Returns: + A :class:`~icalendar.enums.RESOURCE_TYPE` member for + IANA-registered values, a plain :class:`str` for unknown values, or + ``None`` when absent. + """, preserve_unknown=True, ) @@ -71,10 +80,11 @@ class VResource(Component): def geo(self) -> vGeo | None: """The geographic position of this resource per :rfc:`5545#section-3.8.1.6`. - Returns a :class:`~icalendar.prop.geo.vGeo` instance or ``None`` when - no GEO property is set. + Returns: + A :class:`~icalendar.prop.geo.vGeo` instance, or ``None`` when + no GEO property is set. """ return self.get("GEO") -__all__ = ["VResource"] +__all__ = ["Resource"] diff --git a/src/icalendar/cal/todo.py b/src/icalendar/cal/todo.py index 1fc4f07c3..920c4ac08 100644 --- a/src/icalendar/cal/todo.py +++ b/src/icalendar/cal/todo.py @@ -317,16 +317,16 @@ def participants(self): @property def locations(self): """All VLOCATION sub-components of this to-do per :rfc:`9073#section-7.2`.""" - from icalendar.cal.vlocation import VLocation + from icalendar.cal.location import Location - return self.walk(VLocation.name) + return self.walk(Location.name) @property def resources(self): """All VRESOURCE sub-components of this to-do per :rfc:`9073#section-7.3`.""" - from icalendar.cal.vresource import VResource + from icalendar.cal.resource import Resource - return self.walk(VResource.name) + return self.walk(Resource.name) @property def alarms(self) -> Alarms: diff --git a/src/icalendar/enums.py b/src/icalendar/enums.py index 659383ae7..ba4f3d526 100644 --- a/src/icalendar/enums.py +++ b/src/icalendar/enums.py @@ -587,75 +587,77 @@ class TRANSP(StrEnum): class PARTICIPANT_TYPE(StrEnum): # noqa: N801 """Enum for PARTICIPANT-TYPE from :rfc:`9073#section-6.2`. - Identifies the type of participant represented by a PARTICIPANT - component. IANA-registered values are listed in :rfc:`9073#section-11.2.1`. - Unknown values are allowed (IANA-extensible). + This parameter identifies the type of participant represented by a + PARTICIPANT component. IANA-registered values are listed in + :rfc:`9073#section-11.2.1`. Unknown values are allowed, that is, they + are IANA-extensible. Possible values are the following. - :attr:`ACTIVE` - - :attr:`INACTIVE` - - :attr:`SPONSOR` - - :attr:`CONTACT` - :attr:`BOOKING_CONTACT` + - :attr:`CONTACT` - :attr:`EMERGENCY_CONTACT` - - :attr:`PUBLICITY_CONTACT` - - :attr:`PLANNER_CONTACT` + - :attr:`INACTIVE` - :attr:`PERFORMER` + - :attr:`PLANNER_CONTACT` + - :attr:`PUBLICITY_CONTACT` - :attr:`SPEAKER` + - :attr:`SPONSOR` """ ACTIVE = "ACTIVE" - INACTIVE = "INACTIVE" - SPONSOR = "SPONSOR" - CONTACT = "CONTACT" BOOKING_CONTACT = "BOOKING-CONTACT" + CONTACT = "CONTACT" EMERGENCY_CONTACT = "EMERGENCY-CONTACT" - PUBLICITY_CONTACT = "PUBLICITY-CONTACT" - PLANNER_CONTACT = "PLANNER-CONTACT" + INACTIVE = "INACTIVE" PERFORMER = "PERFORMER" + PLANNER_CONTACT = "PLANNER-CONTACT" + PUBLICITY_CONTACT = "PUBLICITY-CONTACT" SPEAKER = "SPEAKER" + SPONSOR = "SPONSOR" class RESOURCE_TYPE(StrEnum): # noqa: N801 """Enum for RESOURCE-TYPE from :rfc:`9073#section-6.3`. - Identifies the type of resource represented by a VRESOURCE component. - IANA-registered values are listed in :rfc:`9073#section-11.2.2`. - Unknown values are allowed (IANA-extensible). + This parameter identifies the type of resource represented by a VRESOURCE + component. IANA-registered values are listed in :rfc:`9073#section-11.2.2`. + Unknown values are allowed, that is, they are IANA-extensible. Possible values are the following. - - :attr:`ROOM` - :attr:`PROJECTOR` - :attr:`REMOTE_CONFERENCE_AUDIO` - :attr:`REMOTE_CONFERENCE_VIDEO` + - :attr:`ROOM` """ - ROOM = "ROOM" PROJECTOR = "PROJECTOR" REMOTE_CONFERENCE_AUDIO = "REMOTE-CONFERENCE-AUDIO" REMOTE_CONFERENCE_VIDEO = "REMOTE-CONFERENCE-VIDEO" + ROOM = "ROOM" class PROXIMITY(StrEnum): """Enum for PROXIMITY from :rfc:`9074#section-8.1`. - Specifies the type of location-based trigger for a - :class:`~icalendar.cal.alarm.Alarm` component. When set, a VLOCATION - sub-component MUST be present to define the location. + This parameter specifies the type of location-based trigger for a + :class:`~icalendar.cal.alarm.Alarm` component. Although the RFC requires + that when PROXIMITY set, a VLOCATION sub-component must be present to + define the location, icalendar doesn't enforce that requirement. Possible values are the following. - :attr:`ARRIVE` - - :attr:`DEPART` - :attr:`CONNECT` + - :attr:`DEPART` - :attr:`DISCONNECT` """ ARRIVE = "ARRIVE" - DEPART = "DEPART" CONNECT = "CONNECT" + DEPART = "DEPART" DISCONNECT = "DISCONNECT" diff --git a/src/icalendar/param.py b/src/icalendar/param.py index e711b36a2..28eb03177 100644 --- a/src/icalendar/param.py +++ b/src/icalendar/param.py @@ -872,14 +872,14 @@ def _convert_order_write(value) -> str: """Indicate the relative ordering of a property amongst multiple properties of the same type. -Conformance: - This property parameter is specified in :rfc:`9073#section-5.1`. - - This parameter MAY be specified on any property that permits multiple - instances in a single component. The value is a positive integer - starting at 1; absent means the property is unordered among those without - an ORDER value. No duplicate ORDER values are allowed within the same - property name on a component. +This property parameter is specified in :rfc:`9073#section-5.1`. + +This parameter may be specified on any property that permits multiple instances +in a single component. The value is a positive integer starting at ``1``. If +it's absent, that means the property is unordered among those without an ORDER +value. Although the RFC states that no duplicate ORDER values are allowed +within the same property name on a component, icalendar doesn't enforce this +requirement. """, convert=_convert_order_read, convert_to=_convert_order_write, @@ -889,28 +889,25 @@ def _convert_order_write(value) -> str: "SCHEMA", """Identify the schema that a STRUCTURED-DATA value conforms to. -Conformance: - This property parameter is specified in :rfc:`9073#section-5.2`. +This property parameter is specified in :rfc:`9073#section-5.2`. - This parameter SHOULD be specified on the STRUCTURED-DATA property. - Its value is a URI identifying the schema the structured data - follows. It supplements the media type given by the FMTTYPE - parameter, which alone may not be specific enough to interpret the - value. +This parameter should be specified on the STRUCTURED-DATA property. Its value +is a URI identifying the schema the structured data follows. It supplements the +media type given by the FMTTYPE parameter, which alone may not be specific +enough to interpret the value. """, ) DERIVED = boolean_parameter("DERIVED", False) """Indicate that a property's value is derived from other property values. -Conformance: - This property parameter is specified in :rfc:`9073#section-5.3`. +This property parameter is specified in :rfc:`9073#section-5.3`. - This parameter MAY be specified on any property whose value can be - derived from the value of one or more other properties. When set to - ``TRUE``, clients MUST NOT update the property's value directly, since - it is expected to be recomputed from the properties it derives from. - The default, when absent, is ``FALSE``. +This parameter may be specified on any property whose value can be derived from +the value of one or more other properties. In accordance with the RFC, when +it's set to ``TRUE``, icalendar doesn't update the property's value directly, +since it's expected to be recomputed from the properties from which it derives. +The default, when absent, is ``FALSE``. """ diff --git a/src/icalendar/tests/test_rfc_9073.py b/src/icalendar/tests/test_rfc_9073.py index faeb04b85..81a80feab 100644 --- a/src/icalendar/tests/test_rfc_9073.py +++ b/src/icalendar/tests/test_rfc_9073.py @@ -11,9 +11,9 @@ PROXIMITY, RELTYPE, RESOURCE_TYPE, + Location, Participant, - VLocation, - VResource, + Resource, vCalAddress, vText, vUri, @@ -27,8 +27,8 @@ "RESOURCE_TYPE", "PROXIMITY", "Participant", - "VLocation", - "VResource", + "Location", + "Resource", ], ) def test_public_names_importable(name): @@ -86,17 +86,17 @@ def test_event_participants_accessor(events): def test_event_locations_accessor(events): - """Event.locations returns typed VLocation instances per :rfc:`9073#section-7.2`.""" + """Event.locations returns typed Location instances per :rfc:`9073#section-7.2`.""" event = events.rfc_9073_vlocation assert len(event.locations) == 1 - assert isinstance(event.locations[0], VLocation) + assert isinstance(event.locations[0], Location) def test_event_resources_accessor(events): - """Event.resources returns typed VResource instances per :rfc:`9073#section-7.3`.""" + """Event.resources returns typed Resource instances per :rfc:`9073#section-7.3`.""" event = events.rfc_9073_vresource assert len(event.resources) == 1 - assert isinstance(event.resources[0], VResource) + assert isinstance(event.resources[0], Resource) def test_participant_type_accessor(events): @@ -112,21 +112,21 @@ def test_participant_calendar_address(events): assert "guido@pycon.example.com" in str(p.calendar_address) -def test_vlocation_in_participant(events): +def test_location_in_participant(events): """VLOCATION nested inside PARTICIPANT is parsed per :rfc:`9073#section-7.1`.""" p = events.rfc_9073_participant.participants[0] assert len(p.locations) == 1 - assert isinstance(p.locations[0], VLocation) + assert isinstance(p.locations[0], Location) -def test_vlocation_name_accessor(events): - """VLocation.location_name returns the NAME property per :rfc:`9073#section-7.2`.""" +def test_location_name_accessor(events): + """Location.location_name returns the NAME property per :rfc:`9073#section-7.2`.""" loc = events.rfc_9073_vlocation.locations[0] assert loc.location_name == "Hydrogen Line Hackerspace Observatory" -def test_vresource_resource_type(events): - """VResource.resource_type returns RESOURCE_TYPE enum per :rfc:`9073#section-7.3`.""" +def test_resource_type_accessor(events): + """Resource.resource_type returns RESOURCE_TYPE enum per :rfc:`9073#section-7.3`.""" res = events.rfc_9073_vresource.resources[0] assert res.resource_type == RESOURCE_TYPE.PROJECTOR @@ -137,10 +137,10 @@ def test_alarm_proximity_typed(events): assert alarm.proximity == PROXIMITY.DEPART -def test_vlocation_in_alarm_registered(events): - """VLOCATION inside VALARM parses as a VLocation instance per :rfc:`9074#section-8`.""" +def test_location_in_alarm_registered(events): + """VLOCATION inside VALARM parses as a Location instance per :rfc:`9074#section-8`.""" alarm = events.rfc_9074_example_proximity.subcomponents[0] - assert isinstance(alarm.subcomponents[0], VLocation) + assert isinstance(alarm.subcomponents[0], Location) def test_order_round_trip(events): From 2208340b0d1ea0fcd31c11afde46cd1890304dae Mon Sep 17 00:00:00 2001 From: Sashank Bhamidi Date: Tue, 24 Nov 2026 03:16:18 +0530 Subject: [PATCH 4/7] fix import order to satisfy ruff --- src/icalendar/__init__.py | 8 ++++---- src/icalendar/cal/__init__.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/icalendar/__init__.py b/src/icalendar/__init__.py index 1d80018ca..e72cc82e5 100644 --- a/src/icalendar/__init__.py +++ b/src/icalendar/__init__.py @@ -13,13 +13,13 @@ FreeBusy, Journal, LazyCalendar, + Location, Participant, + Resource, Timezone, TimezoneDaylight, TimezoneStandard, Todo, - Location, - Resource, ) from icalendar.enums import ( ACTION, @@ -154,16 +154,16 @@ "Journal", "LazyCalendar", "LocalTimezoneMissing", + "Location", "NFields", "Parameters", "Participant", + "Resource", "Timezone", "TimezoneDaylight", "TimezoneStandard", "Todo", "TypesFactory", - "Location", - "Resource", "XCalParsingError", "__version__", "__version_tuple__", diff --git a/src/icalendar/cal/__init__.py b/src/icalendar/cal/__init__.py index 8d975c5bc..a82501a1d 100644 --- a/src/icalendar/cal/__init__.py +++ b/src/icalendar/cal/__init__.py @@ -14,11 +14,11 @@ from .free_busy import FreeBusy from .journal import Journal from .lazy import LazyCalendar +from .location import Location from .participant import Participant +from .resource import Resource from .timezone import Timezone, TimezoneDaylight, TimezoneStandard from .todo import Todo -from .location import Location -from .resource import Resource __all__ = [ "Alarm", @@ -31,11 +31,11 @@ "FreeBusy", "Journal", "LazyCalendar", + "Location", "Participant", + "Resource", "Timezone", "TimezoneDaylight", "TimezoneStandard", "Todo", - "Location", - "Resource", ] From 7b11f2553d131362ce5a63a7d75398d11a489b16 Mon Sep 17 00:00:00 2001 From: Sashank Bhamidi Date: Tue, 24 Nov 2026 03:20:49 +0530 Subject: [PATCH 5/7] fix pre-existing ruff errors from main (RUF036, ISC004) --- src/icalendar/error.py | 12 ++++++------ .../tests/rfc_6321_xcal/test_xml_property.py | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/icalendar/error.py b/src/icalendar/error.py index d49cad92c..b52718476 100644 --- a/src/icalendar/error.py +++ b/src/icalendar/error.py @@ -157,7 +157,7 @@ def __init__( self, message: str, parser: str | type = "", - path: list[str | int] | None | str | int = None, + path: list[str | int] | str | int | None = None, value: object = _default_value, ) -> None: self.path = self._get_path(path) @@ -200,7 +200,7 @@ def reraise_with_path_added( ).with_traceback(e.__traceback__) from e @staticmethod - def _get_path(path: list[str | int] | None | str | int) -> list[str | int]: + def _get_path(path: list[str | int] | str | int | None) -> list[str | int]: """Return the path as a list. :meta private: @@ -216,7 +216,7 @@ def validate_property( cls, jcal_property: list[object], parser: str | type, - path: list[str | int] | None | str | int = None, + path: list[str | int] | str | int | None = None, ) -> None: """Validate a jCal property. @@ -276,7 +276,7 @@ def validate_value_type( expected_type: type[str | int | float | bool] | tuple[type[str | int | float | bool], ...], parser: str | type = "", - path: list[str | int] | None | str | int = None, + path: list[str | int] | str | int | None = None, ) -> None: """Validate the type of a jCal value.""" if not isinstance(jcal, expected_type): @@ -298,7 +298,7 @@ def validate_list_type( jcal: object, expected_type: type[str | int | float | bool], parser: str | type = "", - path: list[str | int] | None | str | int = None, + path: list[str | int] | str | int | None = None, ) -> None: """Validate the type of each item in a jCal list.""" path = cls._get_path(path) @@ -325,7 +325,7 @@ def validate_jcal_token( name: str, kind: str, parser: str | type = "", - path: list[str | int] | None | str | int = None, + path: list[str | int] | str | int | None = None, ) -> None: r"""Validate a jCal ``name`` as a lowercase iCalendar token. diff --git a/src/icalendar/tests/rfc_6321_xcal/test_xml_property.py b/src/icalendar/tests/rfc_6321_xcal/test_xml_property.py index b675efa64..126501a3e 100644 --- a/src/icalendar/tests/rfc_6321_xcal/test_xml_property.py +++ b/src/icalendar/tests/rfc_6321_xcal/test_xml_property.py @@ -175,12 +175,12 @@ def test_xml_property_from_xcal_reads_what_to_xcal_writes(): "properties", [ # case C: an element in another namespace inside of a property - "" - 'Hello', + ("" + 'Hello'), # case D: an element in another namespace inside of an unknown value type - "" + ("" 'Hello' - "", + ""), ], ) def test_xml_property_from_xcal_only_directly_in_properties(properties): From e71c579834ac465123ba0298fb6dde8e2253740a Mon Sep 17 00:00:00 2001 From: Sashank Bhamidi Date: Tue, 24 Nov 2026 03:25:03 +0530 Subject: [PATCH 6/7] fix ruff format on pre-existing ISC004 strings in test_xml_property.py --- .../tests/rfc_6321_xcal/test_xml_property.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/icalendar/tests/rfc_6321_xcal/test_xml_property.py b/src/icalendar/tests/rfc_6321_xcal/test_xml_property.py index 126501a3e..a4872d9cc 100644 --- a/src/icalendar/tests/rfc_6321_xcal/test_xml_property.py +++ b/src/icalendar/tests/rfc_6321_xcal/test_xml_property.py @@ -175,12 +175,16 @@ def test_xml_property_from_xcal_reads_what_to_xcal_writes(): "properties", [ # case C: an element in another namespace inside of a property - ("" - 'Hello'), + ( + "" + 'Hello' + ), # case D: an element in another namespace inside of an unknown value type - ("" - 'Hello' - ""), + ( + "" + 'Hello' + "" + ), ], ) def test_xml_property_from_xcal_only_directly_in_properties(properties): From 692dfc9a8e27adbda0d916b8b0fb9b700309e0b6 Mon Sep 17 00:00:00 2001 From: Sashank Bhamidi Date: Tue, 24 Nov 2026 03:26:58 +0530 Subject: [PATCH 7/7] fix import order and pre-existing RUF036 in time.py --- src/icalendar/cal/component_factory.py | 4 ++-- src/icalendar/prop/dt/time.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/icalendar/cal/component_factory.py b/src/icalendar/cal/component_factory.py index 911e152cf..81c7c6a7a 100644 --- a/src/icalendar/cal/component_factory.py +++ b/src/icalendar/cal/component_factory.py @@ -52,15 +52,15 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: from icalendar.cal.event import Event from icalendar.cal.free_busy import FreeBusy from icalendar.cal.journal import Journal + from icalendar.cal.location import Location from icalendar.cal.participant import Participant + from icalendar.cal.resource import Resource from icalendar.cal.timezone import ( Timezone, TimezoneDaylight, TimezoneStandard, ) from icalendar.cal.todo import Todo - from icalendar.cal.location import Location - from icalendar.cal.resource import Resource self.add_component_class(Calendar) self.add_component_class(Event) diff --git a/src/icalendar/prop/dt/time.py b/src/icalendar/prop/dt/time.py index 79a38cb18..f163eb541 100644 --- a/src/icalendar/prop/dt/time.py +++ b/src/icalendar/prop/dt/time.py @@ -173,7 +173,7 @@ def ical_value(self) -> time: return self.dt @staticmethod - def from_ical(ical: str, timezone: str | None | tzinfo = None) -> time: + def from_ical(ical: str, timezone: str | tzinfo | None = None) -> time: """Convert an ical string into a time. This parses the time forms defined in :rfc:`5545#section-3.3.12`: