@@ -95,8 +95,6 @@ class MyService:
95
95
hang : nexusrpc .Operation [Input , Output ]
96
96
log : nexusrpc .Operation [Input , Output ]
97
97
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 ]
100
98
sync_operation_with_non_async_def : nexusrpc .Operation [Input , Output ]
101
99
# TODO(nexus-prerelease): fix tests of callable instances
102
100
# sync_operation_with_non_async_callable_instance: nexusrpc.Operation[Input, Output]
@@ -263,22 +261,6 @@ def __call__(
263
261
sync_operation_with_non_async_callable_instance ,
264
262
)
265
263
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
-
282
264
@workflow_run_operation
283
265
async def workflow_run_op_link_test (
284
266
self , ctx : WorkflowRunOperationContext , input : Input
@@ -500,23 +482,6 @@ class SyncHandlerHappyPathWithNonAsyncCallableInstance(_TestCase):
500
482
skip = "TODO(nexus-prerelease): fix tests of callable instances"
501
483
502
484
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
-
520
485
class AsyncHandlerHappyPath (_TestCase ):
521
486
operation = "workflow_run_operation_happy_path"
522
487
input = Input ("hello" )
@@ -526,14 +491,6 @@ class AsyncHandlerHappyPath(_TestCase):
526
491
)
527
492
528
493
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
-
537
494
class WorkflowRunOpLinkTestHappyPath (_TestCase ):
538
495
# TODO(nexus-prerelease): fix this test
539
496
skip = "Yields invalid link"
@@ -716,9 +673,7 @@ class NonSerializableOutputFailure(_FailureTestCase):
716
673
SyncHandlerHappyPathNonAsyncDef ,
717
674
# TODO(nexus-prerelease): make callable instance work
718
675
# SyncHandlerHappyPathWithNonAsyncCallableInstance,
719
- SyncHandlerHappyPathWithoutTypeAnnotations ,
720
676
AsyncHandlerHappyPath ,
721
- AsyncHandlerHappyPathWithoutTypeAnnotations ,
722
677
WorkflowRunOpLinkTestHappyPath ,
723
678
],
724
679
)
@@ -807,6 +762,55 @@ async def _test_start_operation(
807
762
assert not any (warnings ), [w .message for w in warnings ]
808
763
809
764
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
+
810
814
async def test_logger_uses_operation_context (env : WorkflowEnvironment , caplog : Any ):
811
815
task_queue = str (uuid .uuid4 ())
812
816
service_name = MyService .__name__
0 commit comments