Counter.deploy() Type

Running mypy (on the Serve quickstart example at Ray Serve: Scalable and Programmable Serving — Ray 2.8.0) gives the error:

error: “Type[Counter]” has no attribute “deploy”

How do you deal with the type for?:

Counter.deploy()

Hi @Henry_Thornton , could you paste your whole script to reproduce the error? (it is working in my local env).

Sure. It is the example from the Serve doc given at link above. I ran mypy again and the same error occurs. Ray 1.13, Python 3.9x, Windows 10

import ray
from ray import serve

ray.init()
serve.start()

@serve.deployment
class Counter:
  def __init__(self):
      self.count = 0

  def __call__(self, request):
      self.count += 1
      return {"count": self.count}

Counter.deploy()

Hi @Henry_Thornton i think this is a bug. However, Ray doesn’t fully support type checking at the moment. Can you please open a GitHub issue?

For now if you want to pass type check you can do typing.cast(Deployment, Counter).