8000 [core] actor constructor type hint should be ActorHandle · Issue #52771 · ray-project/ray · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[core] actor constructor type hint should be ActorHandle #52771
Open
@tekumara

Description

@tekumara

What happened + What you expected to happen

The type hint for remote() on an actor constructor is ObjectRef but should be ActorHandle.

Versions / Dependencies

ray 2.45.0

Reproduction script

import time
from typing import TYPE_CHECKING

import ray
import ray.actor


@ray.remote
class Predictor:
    def __init__(self):
        pass


@ray.remote
class Consumer:
    def __init__(self, predictor: ray.actor.ActorHandle):
        self.predictor = predictor


def main() -> None:
    predictor = Predictor.remote()
    if TYPE_CHECKING:
        reveal_type(predictor)      # pyright - Type of "predictor" is "ObjectRef[Predictor]"
    print(type(predictor))          # runtime - <class 'ray.actor.ActorHandle'>

    consumer = Consumer.remote(predictor) # pyright - error: Argument of type "ObjectRef[Predictor]" cannot be assigned to parameter "__arg0" of type "ActorHandle | ObjectRef[ActorHandle]" in function "remote"

    time.sleep(1)

if __name__ == "__main__":
    main()

Issue Severity

Low: It annoys or frustrates me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Issue that should be fixed within a few weekscommunity-backlogcoreIssues that should be addressed in Ray Coreusability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0