Skip to content

Static Type Checking Bugs #58401

@zschaller27

Description

@zschaller27

What happened + What you expected to happen

I've come across a few issues withe static type checking (specifically using mypy) suggested in the ray documentation.

Firstly, the ray.method decorator doesn't allow for default argument values. It will interpret these functions as having no arguments making it impossible to use any value beyond the default.

Secondly, specifying any options through ray.remote causes an assignment inconsistency with the ActorClass type hint.

Versions / Dependencies

ray version 2.50.1, with "defaults" extra installed.
mypy version 1.18.2

Reproduction script

import ray
from ray.actor import ActorClass, ActorProxy


class Container:
    def __init__(self) -> None:
        self._values: list[int] = []

    @ray.method
    def add_value(self, value: int) -> None:
        self._values.append(value)

    @ray.method
    def get_value(self, index: int = 0) -> int:
        return self._values[index]

Actor_Container: ActorClass[Container] = ray.remote(num_cpus=1)(Container)

if __name__ == "__main__":
    ray.init()
    container_actor: ActorProxy[Container] = Actor_Container.remote()
    ray.get(container_actor.add_value.remote(5))
    ray.get(container_actor.get_value.remote(0))

Issue Severity

Low: It annoys or frustrates me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issue, but not time-criticalbugSomething that is supposed to be working; but isn'tcommunity-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