diff --git a/docs/misc/changelog.rst b/docs/misc/changelog.rst index 65c1487..c097a82 100644 --- a/docs/misc/changelog.rst +++ b/docs/misc/changelog.rst @@ -45,6 +45,7 @@ Others: - Fixed ``stable_baselines3/common/type_aliases.py`` type hint - Fixed ``stable_baselines3/common/torch_layers.py`` type hint - Fixed ``stable_baselines3/common/env_util.py`` type hint +- Fixed ``stable_baselines3/common/preprocessing.py`` type hints - Exposed modules in ``__init__.py`` with the ``__all__`` attribute (@ZikangXiong) - Upgraded GitHub CI/setup-python to v4 and checkout to v3 diff --git a/setup.cfg b/setup.cfg index 045638c..f56f005 100644 --- a/setup.cfg +++ b/setup.cfg @@ -44,7 +44,6 @@ exclude = (?x)( | stable_baselines3/common/off_policy_algorithm.py$ | stable_baselines3/common/on_policy_algorithm.py$ | stable_baselines3/common/policies.py$ - | stable_baselines3/common/preprocessing.py$ | stable_baselines3/common/save_util.py$ | stable_baselines3/common/sb2_compat/rmsprop_tf_like.py$ | stable_baselines3/common/utils.py$ diff --git a/stable_baselines3/common/preprocessing.py b/stable_baselines3/common/preprocessing.py index a406a7d..76dab70 100644 --- a/stable_baselines3/common/preprocessing.py +++ b/stable_baselines3/common/preprocessing.py @@ -122,6 +122,7 @@ def preprocess_obs( elif isinstance(observation_space, spaces.Dict): # Do not modify by reference the original observation + assert isinstance(obs, Dict), f"Expected dict, got {type(obs)}" preprocessed_obs = {} for key, _obs in obs.items(): preprocessed_obs[key] = preprocess_obs(_obs, observation_space[key], normalize_images=normalize_images) @@ -155,7 +156,7 @@ def get_obs_shape( else: return (int(observation_space.n),) elif isinstance(observation_space, spaces.Dict): - return {key: get_obs_shape(subspace) for (key, subspace) in observation_space.spaces.items()} + return {key: get_obs_shape(subspace) for (key, subspace) in observation_space.spaces.items()} # type: ignore[misc] else: raise NotImplementedError(f"{observation_space} observation space is not supported")