diff --git a/pyproject.toml b/pyproject.toml index 7b1c7e7f..cf135e50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,7 +88,7 @@ dev-mypy = [ "frequenz-client-dispatch[cli,dev-mkdocs,dev-noxfile,dev-pytest]", "grpc-stubs == 1.53.0.6", "types-protobuf == 6.30.2.20250703", - "types-python-dateutil == 2.9.0.20250516", + "types-python-dateutil == 2.9.0.20250708", ] dev-noxfile = ["nox == 2025.5.1", "frequenz-repo-config[lib] == 0.13.5"] dev-pylint = [ diff --git a/src/frequenz/client/dispatch/recurrence.py b/src/frequenz/client/dispatch/recurrence.py index fef1993d..2c62bd22 100644 --- a/src/frequenz/client/dispatch/recurrence.py +++ b/src/frequenz/client/dispatch/recurrence.py @@ -197,8 +197,11 @@ def _as_rrule(self, start_time: datetime) -> rrule.rrule: The rrule object. Raises: - ValueError: If the interval is 0. + ValueError: If the interval is 0 or the frequency is UNSPECIFIED. """ + if self.frequency == Frequency.UNSPECIFIED: + raise ValueError("Frequency must be specified") + if self.interval == 0: raise ValueError("Interval must be greater than 0") @@ -208,7 +211,10 @@ def _as_rrule(self, start_time: datetime) -> rrule.rrule: until = end.until rrule_obj = rrule.rrule( - freq=_RRULE_FREQ_MAP[self.frequency], + # Mypy expects a Literal for the `freq` argument, but it can't infer + # that the values from the `_RRULE_FREQ_MAP` dictionary are of the + # correct type. + freq=_RRULE_FREQ_MAP[self.frequency], # type: ignore[arg-type] dtstart=start_time, count=count, until=until,