Skip to content

Commit 958734f

Browse files
committed
Remove operations without type annotations
1 parent 8e23b42 commit 958734f

File tree

1 file changed

+49
-45
lines changed

1 file changed

+49
-45
lines changed

tests/nexus/test_handler.py

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ class MyService:
9595
hang: nexusrpc.Operation[Input, Output]
9696
log: nexusrpc.Operation[Input, Output]
9797
workflow_run_operation_happy_path: nexusrpc.Operation[Input, Output]
98-
workflow_run_operation_without_type_annotations: nexusrpc.Operation[Input, Output]
99-
sync_operation_without_type_annotations: nexusrpc.Operation[Input, Output]
10098
sync_operation_with_non_async_def: nexusrpc.Operation[Input, Output]
10199
# TODO(nexus-prerelease): fix tests of callable instances
102100
# sync_operation_with_non_async_callable_instance: nexusrpc.Operation[Input, Output]
@@ -263,22 +261,6 @@ def __call__(
263261
sync_operation_with_non_async_callable_instance,
264262
)
265263

266-
@sync_operation
267-
async def sync_operation_without_type_annotations(self, ctx, input):
268-
# Despite the lack of type annotations, the input type from the op definition in
269-
# the service definition is used to deserialize the input.
270-
return Output(
271-
value=f"from start method on {self.__class__.__name__} without type annotations: {input}"
272-
)
273-
274-
@workflow_run_operation
275-
async def workflow_run_operation_without_type_annotations(self, ctx, input):
276-
return await ctx.start_workflow(
277-
WorkflowWithoutTypeAnnotations.run,
278-
input,
279-
id=str(uuid.uuid4()),
280-
)
281-
282264
@workflow_run_operation
283265
async def workflow_run_op_link_test(
284266
self, ctx: WorkflowRunOperationContext, input: Input
@@ -500,23 +482,6 @@ class SyncHandlerHappyPathWithNonAsyncCallableInstance(_TestCase):
500482
skip = "TODO(nexus-prerelease): fix tests of callable instances"
501483

502484

503-
class SyncHandlerHappyPathWithoutTypeAnnotations(_TestCase):
504-
operation = "sync_operation_without_type_annotations"
505-
input = Input("hello")
506-
expected = SuccessfulResponse(
507-
status_code=200,
508-
body_json={
509-
"value": "from start method on MyServiceHandler without type annotations: Input(value='hello')"
510-
},
511-
)
512-
expected_without_service_definition = SuccessfulResponse(
513-
status_code=200,
514-
body_json={
515-
"value": "from start method on MyServiceHandler without type annotations: {'value': 'hello'}"
516-
},
517-
)
518-
519-
520485
class AsyncHandlerHappyPath(_TestCase):
521486
operation = "workflow_run_operation_happy_path"
522487
input = Input("hello")
@@ -526,14 +491,6 @@ class AsyncHandlerHappyPath(_TestCase):
526491
)
527492

528493

529-
class AsyncHandlerHappyPathWithoutTypeAnnotations(_TestCase):
530-
operation = "workflow_run_operation_without_type_annotations"
531-
input = Input("hello")
532-
expected = SuccessfulResponse(
533-
status_code=201,
534-
)
535-
536-
537494
class WorkflowRunOpLinkTestHappyPath(_TestCase):
538495
# TODO(nexus-prerelease): fix this test
539496
skip = "Yields invalid link"
@@ -716,9 +673,7 @@ class NonSerializableOutputFailure(_FailureTestCase):
716673
SyncHandlerHappyPathNonAsyncDef,
717674
# TODO(nexus-prerelease): make callable instance work
718675
# SyncHandlerHappyPathWithNonAsyncCallableInstance,
719-
SyncHandlerHappyPathWithoutTypeAnnotations,
720676
AsyncHandlerHappyPath,
721-
AsyncHandlerHappyPathWithoutTypeAnnotations,
722677
WorkflowRunOpLinkTestHappyPath,
723678
],
724679
)
@@ -807,6 +762,55 @@ async def _test_start_operation(
807762
assert not any(warnings), [w.message for w in warnings]
808763

809764

765+
@nexusrpc.service
766+
class MyServiceWithOperationsWithoutTypeAnnotations(MyService):
767+
workflow_run_operation_without_type_annotations: nexusrpc.Operation[Input, Output]
768+
sync_operation_without_type_annotations: nexusrpc.Operation[Input, Output]
769+
770+
771+
class MyServiceHandlerWithOperationsWithoutTypeAnnotations(MyServiceHandler):
772+
@sync_operation
773+
async def sync_operation_without_type_annotations(self, ctx, input):
774+
# Despite the lack of type annotations, the input type from the op definition in
775+
# the service definition is used to deserialize the input.
776+
return Output(
777+
value=f"from start method on {self.__class__.__name__} without type annotations: {input}"
778+
)
779+
780+
@workflow_run_operation
781+
async def workflow_run_operation_without_type_annotations(self, ctx, input):
782+
return await ctx.start_workflow(
783+
WorkflowWithoutTypeAnnotations.run,
784+
input,
785+
id=str(uuid.uuid4()),
786+
)
787+
788+
789+
class SyncHandlerHappyPathWithoutTypeAnnotations(_TestCase):
790+
operation = "sync_operation_without_type_annotations"
791+
input = Input("hello")
792+
expected = SuccessfulResponse(
793+
status_code=200,
794+
body_json={
795+
"value": "from start method on MyServiceHandler without type annotations: Input(value='hello')"
796+
},
797+
)
798+
expected_without_service_definition = SuccessfulResponse(
799+
status_code=200,
800+
body_json={
801+
"value": "from start method on MyServiceHandler without type annotations: {'value': 'hello'}"
802+
},
803+
)
804+
805+
806+
class AsyncHandlerHappyPathWithoutTypeAnnotations(_TestCase):
807+
operation = "workflow_run_operation_without_type_annotations"
808+
input = Input("hello")
809+
expected = SuccessfulResponse(
810+
status_code=201,
811+
)
812+
813+
810814
async def test_logger_uses_operation_context(env: WorkflowEnvironment, caplog: Any):
811815
task_queue = str(uuid.uuid4())
812816
service_name = MyService.__name__

0 commit comments

Comments
 (0)