From ac1bf1c393c074f6d698601f6f8cb9455e57523c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Eduardo=20Bozano?= Date: Thu, 19 Nov 2026 21:31:25 -0300 Subject: [PATCH 1/2] Added the ``DERIVED`` property parameter from :rfc:`9073#section-5.3` --- news/656.feature.3 | 1 + src/icalendar/param.py | 16 ++++++++++++ src/icalendar/prop/text.py | 2 +- .../tests/prop/test_derived_param.py | 25 +++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 news/656.feature.3 create mode 100644 src/icalendar/tests/prop/test_derived_param.py diff --git a/news/656.feature.3 b/news/656.feature.3 new file mode 100644 index 000000000..6209f20be --- /dev/null +++ b/news/656.feature.3 @@ -0,0 +1 @@ +Added the ``DERIVED`` property parameter from :rfc:`9073#section-5.3` (Event Publishing Extensions to iCalendar). It is available on anyproperty (such as :class:`~icalendar.prop.text.vText`) to mark that its value is computed from other properties and must not be edited directly.I used Claude AI (Sonnet 5.5) to assist me with this change.@Mrbozz \ No newline at end of file diff --git a/src/icalendar/param.py b/src/icalendar/param.py index bca86330f..049f28fe2 100644 --- a/src/icalendar/param.py +++ b/src/icalendar/param.py @@ -838,12 +838,28 @@ def _del_GAP(prop): # noqa: N802 GAP = property(_get_GAP, _set_GAP, _del_GAP) +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", diff --git a/src/icalendar/prop/text.py b/src/icalendar/prop/text.py index 3c4e7f5c1..f9a20deff 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, RELTYPE, VALUE def to_jcal(self, name: str) -> list: """The jCal representation of this property according to :rfc:`7265`.""" diff --git a/src/icalendar/tests/prop/test_derived_param.py b/src/icalendar/tests/prop/test_derived_param.py new file mode 100644 index 000000000..d93815829 --- /dev/null +++ b/src/icalendar/tests/prop/test_derived_param.py @@ -0,0 +1,25 @@ +r"""DERIVED property parameter from :rfc:`9073`. + +:rfc:`9073#section-5.3` defines DERIVED to mark that a property's value was +computed from other property values and so MUST NOT be edited directly. +The RFC's own example is a STYLED-DESCRIPTION rendering generated from +another STYLED-DESCRIPTION -- a value type not implemented in this codebase +yet (see :issue:`656`). Exercised here on :class:`~icalendar.prop.text.vText` +instead, since DERIVED may be specified on any property. +""" + +from icalendar import vText + + +def test_derived_default_is_false(): + """DERIVED defaults to False when absent, per RFC 9073 5.3.""" + comment = vText("Generated summary") + assert comment.DERIVED is False + + +def test_derived_round_trips_as_bool(): + """Setting DERIVED to True serializes as DERIVED=TRUE and reads back True.""" + comment = vText("Generated summary") + comment.DERIVED = True + assert comment.DERIVED is True + assert comment.params["DERIVED"] == "TRUE" \ No newline at end of file From ed36afb6c3a517d98f7f9a65a962adaf995b34bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Eduardo=20Bozano?= Date: Thu, 19 Nov 2026 21:50:28 -0300 Subject: [PATCH 2/2] ruff reformat --- src/icalendar/param.py | 1 - src/icalendar/prop/text.py | 2 +- src/icalendar/tests/prop/test_derived_param.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/icalendar/param.py b/src/icalendar/param.py index 049f28fe2..a519189e3 100644 --- a/src/icalendar/param.py +++ b/src/icalendar/param.py @@ -852,7 +852,6 @@ def _del_GAP(prop): # noqa: N802 """ - __all__ = [ "ALTREP", "CN", diff --git a/src/icalendar/prop/text.py b/src/icalendar/prop/text.py index f9a20deff..4991aa62a 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,DERIVED, GAP, LANGUAGE, RELTYPE, VALUE + from icalendar.param import ALTREP, DERIVED, GAP, LANGUAGE, RELTYPE, VALUE def to_jcal(self, name: str) -> list: """The jCal representation of this property according to :rfc:`7265`.""" diff --git a/src/icalendar/tests/prop/test_derived_param.py b/src/icalendar/tests/prop/test_derived_param.py index d93815829..14d1f4df6 100644 --- a/src/icalendar/tests/prop/test_derived_param.py +++ b/src/icalendar/tests/prop/test_derived_param.py @@ -22,4 +22,4 @@ def test_derived_round_trips_as_bool(): comment = vText("Generated summary") comment.DERIVED = True assert comment.DERIVED is True - assert comment.params["DERIVED"] == "TRUE" \ No newline at end of file + assert comment.params["DERIVED"] == "TRUE"