Skip to content

Commit 83f9269

Browse files
committed
Rename error type and shorten pre-defined import policy name
1 parent b0af7e5 commit 83f9269

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

temporalio/worker/workflow_sandbox/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@
5555
# * https://github.com/GrahamDumpleton/wrapt/issues/130
5656

5757
from ._restrictions import (
58-
DisallowedUnintentionalPassthroughError,
5958
RestrictedWorkflowAccessError,
6059
SandboxMatcher,
6160
SandboxRestrictions,
61+
UnintentionalPassthroughError,
6262
)
6363
from ._runner import SandboxedWorkflowRunner
6464

6565
__all__ = [
6666
"RestrictedWorkflowAccessError",
67-
"DisallowedUnintentionalPassthroughError",
67+
"UnintentionalPassthroughError",
6868
"SandboxedWorkflowRunner",
6969
"SandboxMatcher",
7070
"SandboxRestrictions",

temporalio/worker/workflow_sandbox/_importer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
import temporalio.workflow
3939

4040
from ._restrictions import (
41-
DisallowedUnintentionalPassthroughError,
4241
RestrictedModule,
4342
RestrictedWorkflowAccessError,
4443
RestrictionContext,
4544
SandboxRestrictions,
45+
UnintentionalPassthroughError,
4646
)
4747

4848
logger = logging.getLogger(__name__)
@@ -315,7 +315,7 @@ def _maybe_passthrough_module(self, name: str) -> Optional[types.ModuleType]:
315315
if self._is_import_notification_policy_applied(
316316
temporalio.workflow.SandboxImportNotificationPolicy.RAISE_ON_UNINTENTIONAL_PASSTHROUGH
317317
):
318-
raise DisallowedUnintentionalPassthroughError(name)
318+
raise UnintentionalPassthroughError(name)
319319

320320
if self._is_import_notification_policy_applied(
321321
temporalio.workflow.SandboxImportNotificationPolicy.WARN_ON_UNINTENTIONAL_PASSTHROUGH

temporalio/worker/workflow_sandbox/_restrictions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def default_message(qualified_name: str) -> str:
8383

8484

8585
# TODO(amazzeo): is NondeterminisimError appropriate as a subclass?
86-
class DisallowedUnintentionalPassthroughError(temporalio.workflow.NondeterminismError):
86+
class UnintentionalPassthroughError(temporalio.workflow.NondeterminismError):
8787
"""Error that occurs when a workflow unintentionally passes an import to the sandbox when
8888
the import notification policy includes :py:attr:`temporalio.workflow.SandboxImportNotificationPolicy.RAISE_ON_NON_PASSTHROUGH`.
8989
@@ -94,16 +94,16 @@ class DisallowedUnintentionalPassthroughError(temporalio.workflow.Nondeterminism
9494
def __init__(
9595
self, qualified_name: str, *, override_message: Optional[str] = None
9696
) -> None:
97-
"""Create a disallowed unintentional passthrough error."""
97+
"""Create an unintentional passthrough error."""
9898
super().__init__(
9999
override_message
100-
or DisallowedUnintentionalPassthroughError.default_message(qualified_name)
100+
or UnintentionalPassthroughError.default_message(qualified_name)
101101
)
102102
self.qualified_name = qualified_name
103103

104104
@staticmethod
105105
def default_message(qualified_name: str) -> str:
106-
"""Get default message for disallowed unintentional passthrough."""
106+
"""Get default message for unintentional passthrough."""
107107
return f"Module {qualified_name} was not intentionally passed through to the sandbox."
108108

109109

@@ -156,7 +156,7 @@ class methods (including __init__, etc). The check compares the against the
156156
Equivalent to :py:attr:`temporalio.workflow.SandboxImportNotificationPolicy.WARN_ON_DYNAMIC_IMPORT` | :py:attr:`temporalio.workflow.SandboxImportNotificationPolicy.WARN_ON_UNINTENTIONAL_PASSTHROUGH`
157157
"""
158158

159-
import_notification_policy_disallow_unintentional_passthrough: ClassVar[
159+
import_notification_policy_require_explicit_passthrough: ClassVar[
160160
temporalio.workflow.SandboxImportNotificationPolicy
161161
]
162162
"""
@@ -574,7 +574,7 @@ def with_child_unrestricted(self, *child_path: str) -> SandboxMatcher:
574574
temporalio.workflow.SandboxImportNotificationPolicy.WARN_ON_DYNAMIC_IMPORT
575575
| temporalio.workflow.SandboxImportNotificationPolicy.WARN_ON_UNINTENTIONAL_PASSTHROUGH
576576
)
577-
SandboxRestrictions.import_notification_policy_disallow_unintentional_passthrough = (
577+
SandboxRestrictions.import_notification_policy_require_explicit_passthrough = (
578578
temporalio.workflow.SandboxImportNotificationPolicy.WARN_ON_DYNAMIC_IMPORT
579579
| temporalio.workflow.SandboxImportNotificationPolicy.RAISE_ON_UNINTENTIONAL_PASSTHROUGH
580580
)

tests/worker/workflow_sandbox/test_runner.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
WorkflowInterceptorClassInput,
2626
)
2727
from temporalio.worker.workflow_sandbox import (
28-
DisallowedUnintentionalPassthroughError,
2928
RestrictedWorkflowAccessError,
3029
SandboxedWorkflowRunner,
3130
SandboxMatcher,
3231
SandboxRestrictions,
32+
UnintentionalPassthroughError,
3333
)
3434
from tests.helpers import assert_eq_eventually
3535
from tests.worker.workflow_sandbox.testmodules import stateful_module
@@ -516,9 +516,9 @@ class LazyImportWorkflow:
516516
async def run(self) -> None:
517517
try:
518518
import tests.worker.workflow_sandbox.testmodules.lazy_module # noqa: F401
519-
except DisallowedUnintentionalPassthroughError as err:
519+
except UnintentionalPassthroughError as err:
520520
raise ApplicationError(
521-
str(err), type="DisallowedUnintentionalPassthroughError"
521+
str(err), type="UnintentionalPassthroughError"
522522
) from err
523523

524524

@@ -587,7 +587,7 @@ async def test_workflow_sandbox_import_all_warnings(client: Client):
587587
async def test_workflow_sandbox_import_errors(client: Client):
588588
restrictions = dataclasses.replace(
589589
SandboxRestrictions.default,
590-
import_notification_policy=SandboxRestrictions.import_notification_policy_disallow_unintentional_passthrough,
590+
import_notification_policy=SandboxRestrictions.import_notification_policy_require_explicit_passthrough,
591591
# passthrough this test module to avoid a ton of noisy warnings
592592
passthrough_modules=SandboxRestrictions.passthrough_modules_default
593593
| {"tests.worker.workflow_sandbox.test_runner"},
@@ -608,7 +608,7 @@ async def test_workflow_sandbox_import_errors(client: Client):
608608
)
609609

610610
assert isinstance(err.value.cause, ApplicationError)
611-
assert err.value.cause.type == "DisallowedUnintentionalPassthroughError"
611+
assert err.value.cause.type == "UnintentionalPassthroughError"
612612
assert (
613613
"Module tests.worker.workflow_sandbox.testmodules.lazy_module was not intentionally passed through to the sandbox."
614614
== err.value.cause.message

0 commit comments

Comments
 (0)