Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/nexusrpc/_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ class AnotherService:
process: nexusrpc.Operation[ProcessInput, ProcessOutput]
"""

# TODO(preview): error on attempt foo = Operation[int, str](name="bar")
# The input and output types are not accessible on the instance.
# TODO(preview): Support foo = Operation[int, str]? E.g. via
# ops = {name: nexusrpc.Operation[int, int] for name in op_names}
# service_cls = nexusrpc.service(type("ServiceContract", (), ops))
# This will require forming a union of operations disovered via __annotations__
# and __dict__

def decorator(cls: type[ServiceT]) -> type[ServiceT]:
if name is not None and not name:
raise ValueError("Service name must not be empty.")
Expand Down
1 change: 0 additions & 1 deletion src/nexusrpc/handler/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
def service_handler(cls: type[ServiceHandlerT]) -> type[ServiceHandlerT]: ...


# TODO(preview): allow service to be provided as positional argument?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking here was simply that it would be cleaner / more ergonomic to say @service_handler(MyService) rather than @service_handler(service=MyService) seeing as there's only one possible argument currently and even if we add more that would always be the most important argument.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it's the most important argument. There's currently a name arg and my initial take was that it seemed fine to require being explicit. I don't feel strongly about that position so I'd be happy to get this in the todo list if the increased ergonomics are worth it.

@overload
def service_handler(
*,
Expand Down
1 change: 0 additions & 1 deletion src/nexusrpc/handler/_operation_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ def collect_operation_handler_factories_by_method_name(
"""
Collect operation handler methods from a user service handler class.
"""
# TODO(preview): rename op/op_defn variables in this function
factories: dict[str, Callable[[ServiceHandlerT], OperationHandler[Any, Any]]] = {}
service_method_names = (
{op_defn.method_name for op_defn in service.operation_definitions.values()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class TypeAnnotationsOnly(_TestCase):
class A1:
a: Operation[int, str]

# TODO(preview) why is the decorator omitted here?
# A2 intentionally omits @nexusrpc.service at definition time.
# The decorator will be applied in the test function to verify that
# service definitions correctly inherit operations from decorated parent classes.
class A2(A1):
b: Operation[int, str] # type: ignore[reportUninitializedInstanceVariable]

Expand All @@ -44,7 +46,9 @@ class TypeAnnotationsWithValues(_TestCase):
class A1:
a: Operation[int, str] = Operation[int, str](name="a-name")

# TODO(preview) why is the decorator omitted here?
# A2 intentionally omits @nexusrpc.service at definition time.
# The decorator will be applied in the test function to verify that
# service definitions correctly inherit operations from decorated parent classes.
class A2(A1):
b: Operation[int, str] = Operation[int, str](name="b-name")

Expand Down