Skip to content

[core] Generate *.pyi stubs for protobufs #52482

@tekumara

Description

@tekumara

Description

protoc can do this using --pyi-out see here

Use case

Example code that doesn't type check in vscode/pyright

def ping(address: str) -> ray_client_pb2.ClusterInfoResponse:
    with grpc.insecure_channel(address) as channel:
        stub = ray_client_pb2_grpc.RayletDriverStub(channel)
        return stub.ClusterInfo(ray_client_pb2.ClusterInfoRequest(type="PING"))

Errors with:

  /Users/tekumara/code/ray-demo/raydemo/ping.py:9:27 - error: Variable not allowed in type expression (reportInvalidTypeForm)
  /Users/tekumara/code/ray-demo/raydemo/ping.py:12:67 - error: No parameter named "type" (reportCallIssue)

ray 2.44.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issue, but not time-criticalcommunity-backlogcoreIssues that should be addressed in Ray CoreenhancementRequest for new feature and/or capabilitypythonPull requests that update Python codeusability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions