-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time: make time.Weekday data type public so that it can be pattern matched #57
Conversation
From the provided
These suggestions aim to improve code maintainability, reduce redundancy, and ensure consistency with the language's conventions. |
@yj-qin What do you think? |
LGTM. It makes sense. |
@bikallem Can you please rerun |
@peter-jerry-ye Done. |
Looks like CI failing due to CLA. Where/how can I sign it? |
|
We don't require the contributor to sign a CLA anymore, so I just removed the CI check. |
This PR makes
time.Weekday
exportable/public so that consumers of this package can pattern match on it. My use case is that I have to get the weekday of the the parsed PlainDateTime and do certain action based on the returned value.At the moment I have to pattern match on a string value, like so
The
d.weekday()
value is already parsed and deemed to be valid, i.e.PlainDateTime.of
is a success. It seems rather inconvenient to have to handle/pattern-match a case that we know will never occur. Exposing@time.Weekday
aspub
and exporting intime.mbti
will remove this redundant match case. Also in a few instances I have found pattern matching on strings is rather fragile since there are chances of typos in the string which the compiler can't highlight during build time. Finally,Weekday
values are rather stable (.i.e. they are not going to be changed, I think), so I think making it public should be quite future proof.