diff --git a/gymnasium/envs/registration.py b/gymnasium/envs/registration.py index 711d5f20e..515c097e4 100644 --- a/gymnasium/envs/registration.py +++ b/gymnasium/envs/registration.py @@ -567,7 +567,7 @@ def register( disable_env_checker: bool = False, additional_wrappers: tuple[WrapperSpec, ...] = (), vector_entry_point: VectorEnvCreator | str | None = None, - **kwargs: Any, + kwargs: dict | None = None, ): """Registers an environment in gymnasium with an ``id`` to use with :meth:`gymnasium.make` with the ``entry_point`` being a string or callable for creating the environment. @@ -587,7 +587,7 @@ def register( disable_env_checker: If to disable the :class:`gymnasium.wrappers.PassiveEnvChecker` to the environment. additional_wrappers: Additional wrappers to apply the environment. vector_entry_point: The entry point for creating the vector environment - **kwargs: arbitrary keyword arguments which are passed to the environment constructor on initialisation. + kwargs: arbitrary keyword arguments which are passed to the environment constructor on initialisation. Changelogs: v1.0.0 - `autoreset` and `apply_api_compatibility` parameter was removed @@ -598,6 +598,8 @@ def register( global registry, current_namespace ns, name, version = parse_env_id(id) + if kwargs is None: + kwargs = dict() if current_namespace is not None: if ( kwargs.get("namespace") is not None @@ -621,7 +623,7 @@ def register( max_episode_steps=max_episode_steps, order_enforce=order_enforce, disable_env_checker=disable_env_checker, - **kwargs, + kwargs=kwargs, additional_wrappers=additional_wrappers, vector_entry_point=vector_entry_point, )