"type[Counter]" has no attribute "remote"

How severe does this issue affect your experience of using Ray?

  • Low: It annoys or frustrates me for a moment.

mypy gives the following error when I create an actor:

"type[Counter]" has no attribute "remote"  [attr-defined]

Sample code (from Actors — Ray 2.5.1):

import ray

class Counter:
    def __init__(self):
        self.value = 0

    def increment(self):
        self.value += 1
        return self.value

    def get_counter(self):
        return self.value

# Create an actor from this class.
counter = Counter.remote() # <-- mypy error occurs here

I’m using mypy 1.4.1 with ray[default] 2.5.1 in a Linux dev container based on mcr.microsoft.com/devcontainers/python:1-3.10-bookworm. Using VS Code with the ms-python.mypy-type-checker extension.

Any suggestions on how to resolve this?

1 Like

I also ran into this problem with mypy 1.4.1 and ray 2.6.2. It would be also good to suppress the mypy error until this is fixed. Any ideas on how to to do that?

I’ve just been adding # type:ignore comments to the affected lines to appease mypy. Not an ideal solution.

counter = Counter.remote() # type:ignore