Open JakeSummers opened 1 year ago
Given this code:
from ray import serve @serve.deployment(num_replicas=2, ray_actor_options={"num_cpus": 0.2, "num_gpus": 0}) class SayHi: def __init__(self, greeting: str): # Load model self.message = greeting def say_hi(self, name: str) -> str: # Run inference model_output = f"{self.message} {name}" return model_output async def __call__(self, name: str) -> str: return self.say_hi(name) hi_app = SayHi.bind("Hi") # <------------------- MYPY COMPLAINS HERE
And run:
mypy .
This raises the following error:
my_project/ray_serve/say_hi.py:19: error: "type[SayHi]" has no attribute "bind" [attr-defined]
This should raise no error.
ray / ray[serve]
$ poetry show ray name : ray version : 2.7.0 description : Ray provides a simple, universal API for building distributed applications. dependencies - aiohttp >=3.7 - aiohttp-cors * - aiorwlock * - aiosignal * - click >=7.0 - colorful * - fastapi * - filelock * - frozenlist * - gpustat >=1.0.0 - grpcio >=1.32.0 - grpcio >=1.42.0 - jsonschema * - msgpack >=1.0.0,<2.0.0 - numpy >=1.19.3 - opencensus * - packaging * - prometheus-client >=0.7.1 - protobuf >=3.15.3,<3.19.5 || >3.19.5 - py-spy >=0.2.0 - pydantic <2 - pyyaml * - requests * - smart-open * - starlette * - uvicorn * - virtualenv >=20.0.24,<20.21.1 - watchfiles *
mypy:
$ poetry show mypy name : mypy version : 1.5.1 description : Optional static typing for Python dependencies - mypy-extensions >=1.0.0 - tomli >=1.1.0 - typing-extensions >=4.1.0
See above section :)
Medium: It is a significant difficulty but I can work around it.
This seems similar to #25657
This seems related to an ongoing Mypy limitation described here: https://github.com/python/mypy/issues/3135
What happened + What you expected to happen
Given this code:
And run:
This raises the following error:
This should raise no error.
Versions / Dependencies
ray / ray[serve]
mypy:
Reproduction script
See above section :)
Issue Severity
Medium: It is a significant difficulty but I can work around it.