fix(ws): drop deprecated datetime.utcfromtimestamp/utcnow in vendored well_known_types - #154
Open
Xuxchloris wants to merge 1 commit into
Open
Conversation
… well_known_types Python 3.12+ emits DeprecationWarning for datetime.utcfromtimestamp() / datetime.utcnow(); the vendored google.protobuf well_known_types.py still used both. Mirrors the upstream protobuf fix: - _EPOCH_DATETIME_NAIVE = datetime.datetime(1970, 1, 1) (identical value) - GetCurrentTime uses datetime.datetime.now(tz=datetime.timezone.utc) Fixes larksuite#145. Adds timestamp tests (GetCurrentTime under DeprecationWarning-as-error, naive/aware FromDatetime/ToDatetime roundtrips) under lark_oapi/ws/tests.
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.
Fixes #145.
Problem
The vendored
lark_oapi/ws/pb/google/protobuf/internal/well_known_types.pystill callsdatetime.datetime.utcfromtimestamp(0)anddatetime.datetime.utcnow(), both deprecated since Python 3.12 and scheduled for removal — every import of the ws protobuf runtime on Python 3.13/3.14 emits aDeprecationWarning.Change
Mirrors the upstream
google.protobuffix:_EPOCH_DATETIME_NAIVE = datetime.datetime(1970, 1, 1)— identical value, no deprecated call.Timestamp.GetCurrentTime()usesdatetime.datetime.now(tz=datetime.timezone.utc).Tests
New
lark_oapi/ws/tests/test_well_known_types_timestamp.py:GetCurrentTime()underwarnings.simplefilter("error", DeprecationWarning)and sanity-checked againsttime.time().FromDatetime/ToDatetimeroundtrips for naive and timezone-aware datetimes.Verification
python -m pytest lark_oapi/ws/tests/test_well_known_types_timestamp.py— 3/3 pass.python -m pytest(default suite) — 666 pass; the single failingtest_upload_error_propagationcase is the pre-existing Windows-only path-escape issue (CI runs Linux).