Pyright versioning update. Fix #2700 (#2739)

* Moved pygame imports into render

* Formatting

* Make pygame optional for box2d, try to make formatting work

* fix tests, fix pre-commit.

* Update ci linter config.

* fix type hints for latest pyright version and backward compatibility with numpy <= 1.21.5

* pre-commit.

Co-authored-by: Ariel Kwiatkowski <ariel.j.kwiatkowski@gmail.com>
Co-authored-by: Gianluca De Cola <gianluca.decola@ags-it.com>
This commit is contained in:
Gianluca De Cola
2022-04-08 03:19:52 +02:00
committed by GitHub
parent 3fd204dc95
commit 227e246ff6
10 changed files with 26 additions and 21 deletions

View File

@@ -19,7 +19,7 @@ def flatdim(space: Space) -> int:
the space is not defined in ``gym.spaces``.
Example usage::
>>> s = spaces.Dict({"position": spaces.Discrete(2), "velocity": spaces.Discrete(3)})
>>> spaces.flatdim(s)
5
@@ -134,7 +134,7 @@ def _unflatten_multidiscrete(space: MultiDiscrete, x: np.ndarray) -> np.ndarray:
offsets[1:] = np.cumsum(space.nvec.flatten())
(indices,) = np.nonzero(x)
return np.asarray(indices - offsets[:-1], dtype=space.dtype).reshape(space.shape)
return np.asarray(indices - offsets[:-1], dtype=space.dtype).reshape(space.shape) # type: ignore
@unflatten.register(Tuple)