feat: add optional date/datetime/interval parameter classes#3434
Open
inakam wants to merge 1 commit into
Open
Conversation
e956459 to
d8a8693
Compare
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.
d8a8693 to
58455cb
Compare
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add optional variants for all date/datetime/interval parameter classes, filling a gap in the
OptionalParameterMixincoverage.New classes (7 total):
OptionalDateParameterOptionalMonthParameterOptionalYearParameterOptionalDateHourParameterOptionalDateMinuteParameterOptionalDateSecondParameterOptionalDateIntervalParameterEach follows the established 3-line pattern used by existing optional parameters (e.g.
OptionalIntParameter,OptionalFloatParameter):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
OptionalParameterMixinbeing 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:
NoneNoneto empty stringnext_in_enumerationreturningNone