Skip to content

feat: add optional date/datetime/interval parameter classes#3434

Open
inakam wants to merge 1 commit into
spotify:masterfrom
inakam:feat/optional-date-parameters
Open

feat: add optional date/datetime/interval parameter classes#3434
inakam wants to merge 1 commit into
spotify:masterfrom
inakam:feat/optional-date-parameters

Conversation

@inakam

@inakam inakam commented Jun 29, 2026

Copy link
Copy Markdown

Description

Add optional variants for all date/datetime/interval parameter classes, filling a gap in the OptionalParameterMixin coverage.

New classes (7 total):

  • OptionalDateParameter
  • OptionalMonthParameter
  • OptionalYearParameter
  • OptionalDateHourParameter
  • OptionalDateMinuteParameter
  • OptionalDateSecondParameter
  • OptionalDateIntervalParameter

Each follows the established 3-line pattern used by existing optional parameters (e.g. OptionalIntParameter, OptionalFloatParameter):

class OptionalDateParameter(OptionalParameterMixin[datetime.date], DateParameter):
    """Class to parse optional date parameters."""
    expected_type = datetime.date

Motivation and Context

Date and datetime parameters are the only built-in parameter family without optional variants. Users who need optional date parameters must define their own subclass, despite OptionalParameterMixin being designed for exactly this purpose. See existing optional parameter additions in #3406.

Have you tested this?

I have included unit tests. All 7 new parameter classes are tested for:

  • Parsing empty strings to None
  • Parsing valid date/datetime strings to correct types
  • Serializing None to empty string
  • next_in_enumeration returning None
  • Building tasks with config values (both default=None and explicit defaults)

@inakam inakam requested review from a team and dlstadther as code owners June 29, 2026 03:20
@inakam inakam force-pushed the feat/optional-date-parameters branch from e956459 to d8a8693 Compare June 29, 2026 03:24
Add OptionalDateParameter, OptionalMonthParameter, OptionalYearParameter,
OptionalDateHourParameter, OptionalDateMinuteParameter,
OptionalDateSecondParameter, and OptionalDateIntervalParameter.

These follow the same OptionalParameterMixin pattern as the existing
OptionalIntParameter, OptionalFloatParameter, etc. Date/datetime
parameters were the only built-in parameter family without optional
variants.
@inakam inakam force-pushed the feat/optional-date-parameters branch from d8a8693 to 58455cb Compare June 29, 2026 04:47
@dlstadther

Copy link
Copy Markdown
Collaborator

@inakam , does this introduce parameter types you require? Or is it just to contribute towards "completeness"? I'm not inclined to add parameter types if there aren't explicit requested uses of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants