fix(standard-provider): convert all pendulum objects on virtualenv version mismatch#69438
Open
Alwaysgaurav1 wants to merge 2 commits into
Open
Conversation
…envOperator default_kwargs
bdb51a0 to
1f3771f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When using
PythonVirtualenvOperatorwithpendulum<3in the virtual environment while the host runs Pendulum v3, pickling/unpickling fails because Pendulum's internal representations are incompatible across major versions.The existing
_pendulum_to_native_datetimefunction only convertspendulum.DateTimeobjects to nativedatetime.datetime. However, other Pendulum types (Date,Time,Duration,Timezone) can also leak into serialized arguments and return values, causingAttributeErrorexceptions liketype object 'Timezone' has no attribute '_unpickle'.This PR extends both the host-side and guest-side conversion functions to handle all Pendulum types:
pendulum.Date→datetime.datependulum.Time→datetime.timependulum.Duration→datetime.timedeltapendulum.tz.timezone.PendulumTimezone→zoneinfo.ZoneInfoordatetime.timezoneThe guest-side
_native_datetime_to_pendulumfunction in the Jinja2 template is also updated to convert the native types back to their Pendulum equivalents.A new unit test
test_pendulum_to_native_datetime_extendedverifies all the new type conversions.Closes: #50752