-
Notifications
You must be signed in to change notification settings - Fork 292
Make TzInfo picklable #770
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
Conversation
CodSpeed Performance ReportMerging #770 will not alter performanceComparing Summary
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #770 +/- ##
=======================================
Coverage 93.66% 93.66%
=======================================
Files 99 99
Lines 14247 14253 +6
Branches 25 25
=======================================
+ Hits 13344 13350 +6
Misses 897 897
Partials 6 6
Continue to review full report in Codecov by Sentry.
|
please review |
def test_tz_hash() -> None: | ||
v = SchemaValidator(core_schema.datetime_schema()) | ||
lookup: Dict[datetime, str] = {} | ||
for day in range(1, 10): | ||
input_str = f'2022-06-{day:02}T12:13:14-12:1 8000 5' | ||
validated = v.validate_python(input_str) | ||
lookup[validated] = input_str | ||
|
||
assert len(lookup) == 9 | ||
assert ( | ||
lookup[datetime(2022, 6, 8, 12, 13, 14, tzinfo=timezone(timedelta(hours=-12, minutes=-15)))] | ||
== '2022-06-08T12:13:14-12:15' | ||
) | ||
|
||
|
||
def test_tz_cmp() -> None: | ||
v = SchemaValidator(core_schema.datetime_schema()) | ||
validated1 = v.validate_python('2022-06-08T12:13:14-12:15') | ||
validated2 = v.validate_python('2022-06-08T12:13:14-12:14') | ||
|
||
assert validated1 > validated2 | ||
assert validated2 < validated1 |
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.
These are just testing existing properties
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.
otherwise LGTM.
@@ -93,6 +94,7 @@ fn _pydantic_core(py: Python, m: &PyModule) -> PyResult<()> { | |||
m.add_class::<PyMultiHostUrl>()?; | |||
m.add_class::<ArgsKwargs>()?; | |||
m.add_class::<SchemaSerializer>()?; | |||
m.add_class::<TzInfo>()?; |
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.
does this actually need to be exported? If it does, we should have a test for importing it.
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.
It does so that it can be unpickled
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.
The pickle test is already testing that it can be imported
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Fixes #589
Selected Reviewer: @samuelcolvin