-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add built in version coercion #43
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably apply the formatter here. I'm unsure about the date coercions, they seem a little overly fault-tolerant, I think we should only allow ISO format strings to be valid, no numbers as strings or numbers only/
if (type(it) == type(datetime.today())) { | ||
return it | ||
} | ||
if (type(it) == int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really unsure about this one, seems more surprising than useful to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just a file being moved, definitely worth being looked at but I'm not sure if its for this PR (which deals with just the version coercion).
On the topic of datetime parsing, I think dictionaries should be supported, on ISO formats, ISO 8601? I wouldn't support offsets but other than that, that should be doable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, dictionaries sound fine to me.
ISO 8601?
Yeah, the full year, full month and full day must be specified for a string to be a valid date, i.e. "07"
or "30-5"
are rejected, because they are ambiguous, "1970-01-01"
or "1970-1-1"
are valid. No further checks like checking for the max day of month, that's up to the impl of datetime
and more complicated than necessary.
A coercion that naively coerces ints, arrays of ints or strings, or strings, into version.