Skip to content

Commit

Permalink
Merge branch 'main' into 728
Browse files Browse the repository at this point in the history
  • Loading branch information
ozeranskii authored Jan 19, 2025
2 parents 47468e7 + effc857 commit 5cd2993
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions temporalio/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,13 @@ def _apply_to_class(
f"Multiple update methods found for {defn_name} "
f"(at least on {name} and {updates[update_defn.name].fn.__name__})"
)
elif update_defn.validator and not _parameters_identical_up_to_naming(
update_defn.fn, update_defn.validator
):
issues.append(
f"Update validator method {update_defn.validator.__name__} parameters "
f"do not match update method {update_defn.fn.__name__} parameters"
)
else:
updates[update_defn.name] = update_defn

Expand Down
23 changes: 23 additions & 0 deletions tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,26 @@ def test_workflow_init_not__init__():
with pytest.raises(ValueError) as err:
workflow.init(BadWorkflowInit.not__init__)
assert "@workflow.init may only be used on the __init__ method" in str(err.value)


class BadUpdateValidator:
@workflow.update
def my_update(self, a: str):
pass

@my_update.validator # type: ignore
def my_validator(self, a: int):
pass

@workflow.run
async def run(self):
pass


def test_workflow_update_validator_not_update():
with pytest.raises(ValueError) as err:
workflow.defn(BadUpdateValidator)
assert (
"Update validator method my_validator parameters do not match update method my_update parameters"
in str(err.value)
)

0 comments on commit 5cd2993

Please sign in to comment.