From 6366d83cbe84e9931fa0ca3e15e22bb91357d1df Mon Sep 17 00:00:00 2001 From: Sneha Shukla <6regxsw7@mail.grokbot.com> Date: Thu, 19 Nov 2026 17:07:56 +0530 Subject: [PATCH] Add type hints to vDDDTypes.from_ical Annotate the ical argument as a string or existing vDDDTypes instance, the optional timezone as a name, tzinfo, or None, and the return value as DT_TYPE, matching the implementation and sibling from_ical methods. AI disclosure: I used an AI assistant (Grok Bot) to help find a function that still needed type hints for issue #938, that was not already covered by an open pull request, confirm the types from the implementation, call sites, and tests, and prepare the changelog entry. Prompts summarized: search src/icalendar for untyped functions outside files and exact functions in open #938 (and related) pull requests; avoid prop/dt/list.py and vDuration.from_ical (open PR #1873); annotate vDDDTypes.from_ical; add news/938.chore.14 with the required AI disclosure. Output: this commit. --- news/938.chore.14 | 1 + src/icalendar/prop/dt/types.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 news/938.chore.14 diff --git a/news/938.chore.14 b/news/938.chore.14 new file mode 100644 index 000000000..85aedf7a1 --- /dev/null +++ b/news/938.chore.14 @@ -0,0 +1 @@ +Added type annotations to :meth:`~icalendar.prop.dt.types.vDDDTypes.from_ical`. I used an AI assistant (Grok Bot) to help locate an untyped function not already covered by an open pull request, confirm the argument and return types from the implementation and tests, and prepare this changelog entry. @sneha-shukla-dev diff --git a/src/icalendar/prop/dt/types.py b/src/icalendar/prop/dt/types.py index bad267e01..736586ac4 100644 --- a/src/icalendar/prop/dt/types.py +++ b/src/icalendar/prop/dt/types.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Sequence -from datetime import date, datetime, time, timedelta +from datetime import date, datetime, time, timedelta, tzinfo from typing import TYPE_CHECKING, Any, ClassVar, TypeAlias from icalendar.caselessdict import CaselessDict @@ -94,7 +94,9 @@ def to_ical(self) -> bytes: return self.to_property_type().to_ical() @classmethod - def from_ical(cls, ical, timezone=None): + def from_ical( + cls, ical: str | Self, timezone: str | tzinfo | None = None + ) -> DT_TYPE: if isinstance(ical, cls): return ical.dt u = ical.upper()