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

Implemented UTCDatetime constrained type #8158

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

Conversation

Zidane786
Copy link

@Zidane786 Zidane786 commented Nov 17, 2023

Change Summary

The integration of a UTCDateTime constrained type, as mentioned in #8088, allows for validation of whether a given datetime is in the UTC timezone. This is achieved by checking if the offset is 0.

Related issue number

fix #8088

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @sydney-runkle

Copy link

codspeed-hq bot commented Nov 17, 2023

CodSpeed Performance Report

Merging #8158 will not alter performance

Comparing Zidane786:dtutc-constrained-type (870db00) with main (3c96cf9)

Summary

✅ 10 untouched benchmarks

@Zidane786
Copy link
Author

please review

@Zidane786
Copy link
Author

@sydney-runkle can you please review and give some pointers

@sydney-runkle
Copy link
Member

@Zidane786,

Thanks for your work on this! We're working on getting v2.6 out soon.

I'd love to have this new feature included in v2.7, so I'll give this a thorough review once we get 2.6 out :).

@sydney-runkle
Copy link
Member

@Zidane786,

Thanks for your work on this. I think the approach that we want to use here is actually adding support for the annotated types Timezone constraint, as suggested by @Viicos in this comment: #8088 (comment).

@samuelcolvin endorsed that suggestion here: #8088 (comment).

You can see examples of how we've added support for other annotated types annotations such as Gt and Len throughout the pydantic repo :), ex:

def collect_known_metadata(annotations: Iterable[Any]) -> tuple[dict[str, Any], list[Any]]:
.

Ping me if you have any follow up questions + when you need a review :). Thanks for your work on this!

@Zidane786
Copy link
Author

let me take a look, and work on it. Will reach out to you if needed any input from your end. Thank you.

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

Successfully merging this pull request may close these issues.

Constrainted datetime based on timezone offset / UTCDateTime
2 participants