Skip to content

Commit

Permalink
type fix
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Aug 20, 2024
1 parent 16f4337 commit fa84b3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions kscale/formats/mjcf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# mypy: disable-error-code="operator,union-attr"
"""Defines common types and functions for exporting MJCF files.
API reference:
Expand Down Expand Up @@ -443,14 +442,14 @@ def __init__(
compiler (Compiler, optional): The compiler settings.
"""
self.robot_name = robot_name
self.output_dir = output_dir
self.output_dir = Path(output_dir)
self.compiler = compiler
self._set_clean_up()
self.tree = ET.parse(self.output_dir / f"{self.robot_name}.xml")

def _set_clean_up(self) -> None:
try:
import mujoco
import mujoco # type: ignore[import-not-found]
except ImportError as e:
raise ImportError(
"Please install the package with Mujoco as a dependency, using "
Expand Down Expand Up @@ -486,13 +485,17 @@ def adapt_world(self) -> None:
compiler = self.compiler.to_xml(compiler)

worldbody = root.find("worldbody")
if worldbody is None:
raise ValueError("No worldbody found in the XML file")

new_root_body = Body(name="root", pos=(0, 0, 0), quat=(1, 0, 0, 0)).to_xml()

# List to store items to be moved to the new root body
items_to_move = []
# Gather all children (geoms and bodies) that need to be moved under the new root body
for element in worldbody:
items_to_move.append(element)

# Move gathered elements to the new root body
for item in items_to_move:
worldbody.remove(item)
Expand Down
2 changes: 1 addition & 1 deletion kscale/store/pybullet.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def main(args: Sequence[str] | None = None) -> None:
parsed_args = parser.parse_args(args)

try:
import pybullet as p
import pybullet as p # type: ignore[import-not-found]
except ImportError:
raise ImportError("pybullet is required to run this script")

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mypy: disable-error-code="import-untyped"
# mypy: disable-error-code="import-untyped, import-not-found"
#!/usr/bin/env python
"""Setup script for the project."""

Expand Down

0 comments on commit fa84b3a

Please sign in to comment.