Open
Description
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.