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

Support dates only starting from 1AC #79

Closed
wants to merge 1 commit into from
Closed

Conversation

tvuotila
Copy link

@tvuotila tvuotila commented Nov 25, 2024

Fixes pydantic/pydantic#10967

Python has datetime.MINYEAR = 1 source. It is not possible to create datetime.date or datetime.datetime that has year smaller than 1.

This is the first time I have even looked at Rust code, thus there might be a lot of mistakes.

Thank you @changhc for providing an changelog example in #77

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.55%. Comparing base (0ffbcbb) to head (7e3b656).
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #79      +/-   ##
==========================================
- Coverage   99.12%   98.55%   -0.58%     
==========================================
  Files           6        6              
  Lines         917      966      +49     
==========================================
+ Hits          909      952      +43     
- Misses          8       14       +6     
Files with missing lines Coverage Δ
src/date.rs 99.44% <100.00%> (-0.56%) ⬇️
src/datetime.rs 100.00% <ø> (ø)
src/lib.rs 91.66% <ø> (ø)

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5128eaa...7e3b656. Read the comment docs.

Copy link
Contributor

@changhc changhc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm it's unfortunate that there's this constraint in date. I don't think that issue should be addressed here though. It's an issue in python and therefore fixes should be implemented in pydantic-core.

@davidhewitt
Copy link
Contributor

Thanks for the PR! Agreed with @changhc, I think given 0000 is accepted in RFC 3339 / ISO 8601 we should instead introduce a check in pydantic-core when converting to Python datetimes.

@tvuotila
Copy link
Author

RFC 3339 / ISO 8601 is quite clear that the year should be between 0000 and 9999. Thus, I will close this PR.

@tvuotila tvuotila closed this Nov 26, 2024
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.

Date field with year zero will raise ValueError instead of ValidationError
3 participants