Skip to content

Commit fd62152

Browse files
[core] Fixes static type hints for ActorClass when setting options through ray.remote (#58439)
Fixes static type hints for ActorClass when setting options through ray.remote Closes #58401 and #58402 cc @richardliaw @edoakes @pcmoritz --------- Signed-off-by: will.lin <[email protected]>
1 parent 25a01ce commit fd62152

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

python/ray/_private/worker.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3398,6 +3398,10 @@ def _make_remote(function_or_class, options):
33983398

33993399

34003400
class RemoteDecorator(Protocol):
3401+
@overload
3402+
def __call__(self, __t: Type[T]) -> ActorClass[T]:
3403+
...
3404+
34013405
@overload
34023406
def __call__(self, __function: Callable[[], R]) -> RemoteFunctionNoArgs[R]:
34033407
...
@@ -3458,12 +3462,6 @@ def __call__(
34583462
) -> RemoteFunction9[R, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9]:
34593463
...
34603464

3461-
# Pass on typing actors for now. The following makes it so no type errors
3462-
# are generated for actors.
3463-
@overload
3464-
def __call__(self, __t: type) -> Any:
3465-
...
3466-
34673465

34683466
@overload
34693467
def remote(__t: Type[T]) -> ActorClass[T]:

python/ray/actor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,6 @@ def bind(
300300
...
301301

302302

303-
@overload
304-
def method(
305-
__method: Callable[[Any], _Ret],
306-
) -> _RemoteMethodNoArgs[_Ret]:
307-
...
308-
309-
310303
@overload
311304
def method(
312305
__method: Callable[[Any, _T0], _Ret],
@@ -377,6 +370,13 @@ def method(
377370
...
378371

379372

373+
@overload
374+
def method(
375+
__method: Callable[[Any], _Ret],
376+
) -> _RemoteMethodNoArgs[_Ret]:
377+
...
378+
379+
380380
@overload
381381
def method(
382382
*,

0 commit comments

Comments
 (0)