From 79bd70bce91c81b8dff00282b1469b002aacb667 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Thu, 9 Jan 2025 11:13:51 -0500 Subject: [PATCH 1/4] Failing test --- tests/test_workflow.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_workflow.py b/tests/test_workflow.py index 1c3478a91..30cc4db76 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -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) + ) From 0f264a70902b38a4a3b6f5f9ea27d6c298ae63da Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Thu, 9 Jan 2025 11:13:58 -0500 Subject: [PATCH 2/4] Fix --- temporalio/workflow.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/temporalio/workflow.py b/temporalio/workflow.py index e2d59b1a5..315150351 100644 --- a/temporalio/workflow.py +++ b/temporalio/workflow.py @@ -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 From c7357a99b355ba77d9a721ef2a6ecb680d17a19c Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Thu, 16 Jan 2025 13:14:57 -0500 Subject: [PATCH 3/4] Restrict to failing tests --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a8c0d336d..4ba459f55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,7 @@ bridge-lint = { cmd = "cargo clippy -- -D warnings", cwd = "temporalio/bridge" } lint-docs = "pydocstyle --ignore-decorators=overload" lint-types = "mypy --namespace-packages --check-untyped-defs ." run-bench = "python scripts/run_bench.py" -test = "pytest" +test = "pytest tests/worker/test_workflow.py::test_unfinished_handler_on_workflow_termination" # Install local, run single pytest with env var, uninstall local [tool.poe.tasks.test-dist-single] From d644ac80b800255a6ecd9feabe5290c7a2488465 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Fri, 17 Jan 2025 20:14:57 -0500 Subject: [PATCH 4/4] Revert "Restrict to failing tests" This reverts commit 18be6ed33c09f1133981ebde3fec0ab1bc763f12. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4ba459f55..a8c0d336d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,7 @@ bridge-lint = { cmd = "cargo clippy -- -D warnings", cwd = "temporalio/bridge" } lint-docs = "pydocstyle --ignore-decorators=overload" lint-types = "mypy --namespace-packages --check-untyped-defs ." run-bench = "python scripts/run_bench.py" -test = "pytest tests/worker/test_workflow.py::test_unfinished_handler_on_workflow_termination" +test = "pytest" # Install local, run single pytest with env var, uninstall local [tool.poe.tasks.test-dist-single]