Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jamesrswift
Copy link
Member

A coercion that naively coerces ints, arrays of ints or strings, or strings, into version.

@jamesrswift jamesrswift linked an issue Jul 24, 2024 that may be closed by this pull request
Copy link
Member

@tingerrr tingerrr left a 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) {
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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.

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.

Add built-in version schema and coercion
2 participants