diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50df300f0..0cea21b90 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,17 @@ --- repos: - repo: https://github.com/python/black - rev: 22.3.0 + rev: 23.12.1 hooks: - id: black - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 + rev: v2.2.6 hooks: - id: codespell args: - --ignore-words-list=linz - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 7.0.0 hooks: - id: flake8 args: @@ -22,7 +22,7 @@ repos: - --show-source - --statistics - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort args: ["--profile", "black"] @@ -36,7 +36,7 @@ repos: # - --convention=google # additional_dependencies: ["toml"] - repo: https://github.com/asottile/pyupgrade - rev: v2.32.0 + rev: v3.15.0 hooks: - id: pyupgrade args: ["--py37-plus"] diff --git a/docs/_scripts/gen_gifs.py b/docs/_scripts/gen_gifs.py index e0712e487..3bdc92282 100644 --- a/docs/_scripts/gen_gifs.py +++ b/docs/_scripts/gen_gifs.py @@ -49,7 +49,6 @@ state, info = env.reset() terminated, truncated = False, False while not (terminated or truncated) and len(frames) <= LENGTH: - frame = env.render() frames.append(Image.fromarray(frame)) action = env.action_space.sample() diff --git a/docs/content/create_env_tutorial.md b/docs/content/create_env_tutorial.md index 610b2b390..3773c996d 100644 --- a/docs/content/create_env_tutorial.md +++ b/docs/content/create_env_tutorial.md @@ -204,7 +204,7 @@ class SimpleEnv(MiniGridEnv): # Generate the surrounding walls self.grid.wall_rect(0, 0, width, height) - # Generate verical separation wall + # Generate vertical separation wall for i in range(0, height): self.grid.set(5, i, Wall()) diff --git a/minigrid/core/mission.py b/minigrid/core/mission.py index 8e62410b2..61bdd1d10 100644 --- a/minigrid/core/mission.py +++ b/minigrid/core/mission.py @@ -169,7 +169,6 @@ def __repr__(self) -> str: def __eq__(self, other) -> bool: """Check whether ``other`` is equivalent to this instance.""" if isinstance(other, MissionSpace): - # Check that place holder lists are the same if self.ordered_placeholders is not None: # Check length @@ -189,10 +188,8 @@ def __eq__(self, other) -> bool: other_mission = other.mission_func(*test_placeholders) return mission == other_mission else: - # Check that other is also None if other.ordered_placeholders is None: - # Check mission string is the same mission = self.mission_func() other_mission = other.mission_func() diff --git a/minigrid/envs/babyai/other.py b/minigrid/envs/babyai/other.py index de994abc7..57e2c2430 100644 --- a/minigrid/envs/babyai/other.py +++ b/minigrid/envs/babyai/other.py @@ -160,7 +160,6 @@ class FindObjS5(RoomGridLevel): """ def __init__(self, room_size=5, max_steps: int | None = None, **kwargs): - if max_steps is None: max_steps = 20 * room_size**2 diff --git a/minigrid/envs/fourrooms.py b/minigrid/envs/fourrooms.py index 3b83214b9..71c25f641 100644 --- a/minigrid/envs/fourrooms.py +++ b/minigrid/envs/fourrooms.py @@ -91,7 +91,6 @@ def _gen_grid(self, width, height): # For each row of rooms for j in range(0, 2): - # For each column for i in range(0, 2): xL = i * room_w diff --git a/minigrid/envs/gotoobject.py b/minigrid/envs/gotoobject.py index db8fa5ecb..547027183 100644 --- a/minigrid/envs/gotoobject.py +++ b/minigrid/envs/gotoobject.py @@ -64,7 +64,6 @@ class GoToObjectEnv(MiniGridEnv): """ def __init__(self, size=6, numObjs=2, max_steps: int | None = None, **kwargs): - self.numObjs = numObjs self.size = size # Types of objects to be generated diff --git a/minigrid/envs/multiroom.py b/minigrid/envs/multiroom.py index 47802a77d..ff4f26a3d 100644 --- a/minigrid/envs/multiroom.py +++ b/minigrid/envs/multiroom.py @@ -145,7 +145,6 @@ def _gen_grid(self, width, height): # For each room for idx, room in enumerate(roomList): - topX, topY = room.top sizeX, sizeY = room.size @@ -242,7 +241,6 @@ def _placeRoom(self, numLeft, roomList, minSz, maxSz, entryDoorWall, entryDoorPo # Try placing the next room for i in range(0, 8): - # Pick which wall to place the out door on wallSet = {0, 1, 2, 3} wallSet.remove(entryDoorWall) diff --git a/minigrid/envs/playground.py b/minigrid/envs/playground.py index 0a0341cac..613e97b1e 100644 --- a/minigrid/envs/playground.py +++ b/minigrid/envs/playground.py @@ -43,7 +43,6 @@ def _gen_grid(self, width, height): # For each row of rooms for j in range(0, 3): - # For each column for i in range(0, 3): xL = i * roomW diff --git a/minigrid/envs/wfc/graphtransforms.py b/minigrid/envs/wfc/graphtransforms.py index c2ea41297..391047747 100644 --- a/minigrid/envs/wfc/graphtransforms.py +++ b/minigrid/envs/wfc/graphtransforms.py @@ -51,7 +51,6 @@ class GraphTransforms: @staticmethod def minigrid_to_bitmap(grids): - layout = grids[..., 0] bitmap = np.zeros_like(layout) bitmap[layout == 2] = 1 @@ -97,7 +96,6 @@ def minigrid_to_dense_graph( def minigrid_layout_to_dense_graph( layouts: np.ndarray, remove_border=True, node_attr=None, edge_config=None ) -> tuple[list[nx.Graph], dict[str, list[nx.Graph]]]: - assert ( layouts.ndim == 3 ), f"Wrong dimensions for minigrid layout, expected 3 dimensions, got {layouts.ndim}." @@ -165,7 +163,6 @@ def features_to_dense_graph( dim_grid: tuple, edge_config: dict[str, EdgeDescriptor] = None, ) -> tuple[list[nx.Graph], dict[str, list[nx.Graph]]]: - graphs = [] edge_graphs = defaultdict(list) for m in range(features[list(features.keys())[0]].shape[0]): @@ -191,7 +188,6 @@ def features_to_dense_graph( def graph_features_to_minigrid( graph_features: dict[str, np.ndarray], shape: tuple[int, int], padding=1 ) -> np.ndarray: - features = graph_features.copy() node_attributes = list(features.keys()) @@ -285,7 +281,6 @@ def graph_features_to_minigrid( def get_node_features( graph: nx.Graph, pattern_shape, node_attributes: list[str] = None, reshape=True ) -> tuple[np.ndarray, list[str]]: - if node_attributes is None: # Get node attributes from some node node_attributes = list(next(iter(graph.nodes.data()))[1].keys()) @@ -313,7 +308,6 @@ def get_node_features( def dense_graph_to_minigrid( graph: nx.Graph, shape: tuple[int, int], padding=1 ) -> np.ndarray: - pattern_shape = (shape[0] - 2 * padding, shape[1] - 2 * padding) features, node_attributes = GraphTransforms.get_node_features( graph, pattern_shape, node_attributes=None @@ -340,7 +334,6 @@ def get_edge_layers( node_attr: list[str], dim_grid: tuple[int, int], ) -> dict[str, nx.Graph]: - navigable_nodes = ["empty", "start", "goal", "moss"] non_navigable_nodes = ["wall", "lava"] assert all([isinstance(n, tuple) for n in graph.nodes]) diff --git a/tests/test_envs.py b/tests/test_envs.py index 1027676cb..7b62ec128 100644 --- a/tests/test_envs.py +++ b/tests/test_envs.py @@ -260,7 +260,6 @@ def test_interactive_mode(env_id): def test_mission_space(): - # Test placeholders mission_space = MissionSpace( mission_func=lambda color, obj_type: f"Get the {color} {obj_type}.", diff --git a/tests/utils.py b/tests/utils.py index 1a8f27cb3..f1a3ae5a3 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -38,7 +38,7 @@ def assert_equals(a, b, prefix=None): b: second data structure prefix: prefix for failed assertion message for types and dicts """ - assert type(a) == type(b), f"{prefix}Differing types: {a} and {b}" + assert type(a) is type(b), f"{prefix}Differing types: {a} and {b}" if isinstance(a, dict): assert list(a.keys()) == list(b.keys()), f"{prefix}Key sets differ: {a} and {b}"