Repository navigation
Return None for an unset expiration_time in ActivityHandle.describe() - #2016
Open
LindseyZ1205 wants to merge 1 commit into
Open
LindseyZ1205 wants to merge 1 commit into
LindseyZ1205 wants to merge 1 commit into
Conversation
ActivityExecutionDescription.expiration_time has been typed datetime | None since temporalio#1782, but describe() still returned a naive datetime.min when the server doesn't set it.
This branch has not been deployed
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.
ActivityExecutionDescription.expiration_timeis typeddatetime | None, and documented as the time at which the activity's schedule-to-close timeout expires. When a Standalone Activity has no schedule-to-close timeout, for example when it's started with onlystart_to_close_timeout, the server doesn't setexpiration_time, andActivityHandle.describe()returnsdatetime.min, which is naive, instead ofNone. #1782 changed the annotation fromdatetimetodatetime | None, but kept thedatetime.mindefault.NexusOperationExecutionDescription.expiration_timeisNonein this case.So code that follows the annotation, such as:
raises
TypeError: can't subtract offset-naive and offset-aware datetimesfor an activity started with onlystart_to_close_timeout.This change returns
Nonein this case, and adds afixedchangelog fragment.test_describe_without_schedule_to_close_timeoutintests/test_activity.pystarts an activity with onlystart_to_close_timeoutand checks thatdescribe()returnsexpiration_time=None. Onmain, it fails withassert datetime.datetime(1, 1, 1, 0, 0) is None.Validation, with Python 3.12, the local dev server, and the Rust bridge of the temporalio 1.34.0 wheel:
tests/test_activity.pypasses (35 tests). I didn't run the rest of the suite, since nothing else in the SDK reads this field.ruff check --select Iandruff format --check(ruff 0.15.22), pyright 1.1.403, basedpyright 1.34.0 andmypy --namespace-packages --check-untyped-defspass on the changed files, and pydocstyle passes on the changed source file.