Skip to content

Commit 3fadf5b

Browse files
committed
Add 'type: ignore' to most ray calls in the worker module
1 parent 152dda2 commit 3fadf5b

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

tianshou/env/worker/ray.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# mypy: disable-error-code=unused-ignore
12
import contextlib
23
from collections.abc import Callable
34
from typing import Any
@@ -12,9 +13,6 @@
1213
import ray
1314

1415

15-
# mypy: disable-error-code="unused-ignore"
16-
17-
1816
class _SetAttrWrapper(gym.Wrapper):
1917
def set_env_attr(self, key: str, value: Any) -> None:
2018
setattr(self.env.unwrapped, key, value)
@@ -34,15 +32,15 @@ def __init__(
3432
super().__init__(env_fn)
3533

3634
def get_env_attr(self, key: str) -> Any:
37-
return ray.get(self.env.get_env_attr.remote(key))
35+
return ray.get(self.env.get_env_attr.remote(key)) # type: ignore
3836

3937
def set_env_attr(self, key: str, value: Any) -> None:
40-
ray.get(self.env.set_env_attr.remote(key, value))
38+
ray.get(self.env.set_env_attr.remote(key, value)) # type: ignore
4139

4240
def reset(self, **kwargs: Any) -> Any:
4341
if "seed" in kwargs:
4442
super().seed(kwargs["seed"])
45-
return ray.get(self.env.reset.remote(**kwargs))
43+
return ray.get(self.env.reset.remote(**kwargs)) # type: ignore
4644

4745
@staticmethod
4846
def wait( # type: ignore
@@ -51,29 +49,29 @@ def wait( # type: ignore
5149
timeout: float | None = None,
5250
) -> list["RayEnvWorker"]:
5351
results = [x.result for x in workers]
54-
ready_results, _ = ray.wait(results, num_returns=wait_num, timeout=timeout)
52+
ready_results, _ = ray.wait(results, num_returns=wait_num, timeout=timeout) # type: ignore
5553
return [workers[results.index(result)] for result in ready_results]
5654

5755
def send(self, action: np.ndarray | None, **kwargs: Any) -> None:
5856
# self.result is actually a handle
5957
if action is None:
60-
self.result = self.env.reset.remote(**kwargs)
58+
self.result = self.env.reset.remote(**kwargs) # type: ignore
6159
else:
62-
self.result = self.env.step.remote(action)
60+
self.result = self.env.step.remote(action) # type: ignore
6361

6462
def recv(self) -> gym_new_venv_step_type:
6563
return ray.get(self.result) # type: ignore
6664

6765
def seed(self, seed: int | None = None) -> list[int] | None:
6866
super().seed(seed)
6967
try:
70-
return ray.get(self.env.seed.remote(seed))
68+
return ray.get(self.env.seed.remote(seed)) # type: ignore
7169
except (AttributeError, NotImplementedError):
72-
self.env.reset.remote(seed=seed)
70+
self.env.reset.remote(seed=seed) # type: ignore
7371
return None
7472

7573
def render(self, **kwargs: Any) -> Any:
76-
return ray.get(self.env.render.remote(**kwargs))
74+
return ray.get(self.env.render.remote(**kwargs)) # type: ignore
7775

7876
def close_env(self) -> None:
79-
ray.get(self.env.close.remote())
77+
ray.get(self.env.close.remote()) # type: ignore

0 commit comments

Comments
 (0)