Skip to content

Commit 4436f89

Browse files
jorenhamCopilot
andauthored
fix incorrect TypeVar use in core for RenderFrame (#1560)
Co-authored-by: Copilot <copilot@github.com>
1 parent 877ba30 commit 4436f89

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

gymnasium/core.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from copy import deepcopy
6-
from typing import TYPE_CHECKING, Any, Generic, SupportsFloat, TypeVar
6+
from typing import TYPE_CHECKING, Any, Generic, SupportsFloat, TypeAlias, TypeVar
77

88
import numpy as np
99

@@ -16,7 +16,8 @@
1616

1717
ObsType = TypeVar("ObsType")
1818
ActType = TypeVar("ActType")
19-
RenderFrame = TypeVar("RenderFrame")
19+
20+
RenderFrame: TypeAlias = str | np.ndarray | tuple[np.ndarray, np.ndarray]
2021

2122

2223
class Env(Generic[ObsType, ActType]):
@@ -302,7 +303,7 @@ class Wrapper(
302303
If you inherit from :class:`Wrapper`, don't forget to call ``super().__init__(env)``
303304
"""
304305

305-
def __init__(self, env: Env[ObsType, ActType]):
306+
def __init__(self, env: Env[WrapperObsType, WrapperActType]):
306307
"""Wraps an environment to allow a modular transformation of the :meth:`step` and :meth:`reset` methods.
307308
308309
Args:

gymnasium/wrappers/rendering.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
class RenderCollection(
3535
gym.Wrapper[ObsType, ActType, ObsType, ActType],
36-
Generic[ObsType, ActType, RenderFrame],
36+
Generic[ObsType, ActType],
3737
gym.utils.RecordConstructorArgs,
3838
):
3939
"""Collect rendered frames of an environment such ``render`` returns a ``list[RenderedFrame]``.
@@ -161,7 +161,7 @@ def render(self) -> list[RenderFrame]:
161161

162162
class RecordVideo(
163163
gym.Wrapper[ObsType, ActType, ObsType, ActType],
164-
Generic[ObsType, ActType, RenderFrame],
164+
Generic[ObsType, ActType],
165165
gym.utils.RecordConstructorArgs,
166166
):
167167
"""Records videos of environment episodes using the environment's render function.

0 commit comments

Comments
 (0)