Skip to content

Commit 80a2d48

Browse files
authored
Clean up type annotation in the environment files. (#575)
## Summary Clean up type annotations in the environment files ## Detailed description - Type annotation were not properly done at the start of the project, and that propagated over time to all environment files. - This cleans that up.
1 parent 7761419 commit 80a2d48

19 files changed

Lines changed: 118 additions & 81 deletions

isaaclab_arena_environments/cli.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6+
from __future__ import annotations
7+
68
import argparse
79
import importlib
8-
from typing import Any
10+
from typing import TYPE_CHECKING, Any
911

1012
from isaaclab_arena.cli.isaaclab_arena_cli import get_isaaclab_arena_cli_parser
1113
from isaaclab_arena_environments.cube_goal_pose_environment import CubeGoalPoseEnvironment
@@ -30,11 +32,8 @@
3032
from isaaclab_arena_environments.press_button_environment import PressButtonEnvironment
3133
from isaaclab_arena_environments.tabletop_place_upright_environment import TableTopPlaceUprightEnvironment
3234

33-
# NOTE(alexmillane, 2025.09.04): There is an issue with type annotation in this file.
34-
# We cannot annotate types which require the simulation app to be started in order to
35-
# import, because this file is used to retrieve CLI arguments, so it must be imported
36-
# before the simulation app is started.
37-
# TODO(alexmillane, 2025.09.04): Fix this.
35+
if TYPE_CHECKING:
36+
from isaaclab_arena.environments.arena_env_builder import ArenaEnvBuilder
3837

3938

4039
# Collection of the available example environments
@@ -118,7 +117,7 @@ def get_isaaclab_arena_environments_cli_parser(
118117
return args_parser
119118

120119

121-
def get_arena_builder_from_cli(args_cli: argparse.Namespace): # -> tuple[ManagerBasedRLEnvCfg, str]:
120+
def get_arena_builder_from_cli(args_cli: argparse.Namespace) -> ArenaEnvBuilder:
122121
from isaaclab_arena.environments.arena_env_builder import ArenaEnvBuilder
123122

124123
# Get the example environment

isaaclab_arena_environments/cube_goal_pose_environment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6+
from __future__ import annotations
7+
68
import argparse
9+
from typing import TYPE_CHECKING
710

811
from isaaclab_arena_environments.example_environment_base import ExampleEnvironmentBase
912

10-
# NOTE(alexmillane, 2025.09.04): There is an issue with type annotation in this file.
11-
# We cannot annotate types which require the simulation app to be started in order to
12-
# import, because this file is used to retrieve CLI arguments, so it must be imported
13-
# before the simulation app is started.
14-
# TODO(alexmillane, 2025.09.04): Fix this.
13+
if TYPE_CHECKING:
14+
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
1515

1616

1717
class CubeGoalPoseEnvironment(ExampleEnvironmentBase):
@@ -21,7 +21,7 @@ class CubeGoalPoseEnvironment(ExampleEnvironmentBase):
2121

2222
name = "cube_goal_pose"
2323

24-
def get_env(self, args_cli: argparse.Namespace):
24+
def get_env(self, args_cli: argparse.Namespace) -> IsaacLabArenaEnvironment:
2525

2626
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
2727
from isaaclab_arena.scene.scene import Scene

isaaclab_arena_environments/dexsuite_lift_environment.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
from __future__ import annotations
88

99
import argparse
10+
from typing import TYPE_CHECKING
1011

1112
from isaaclab_arena_environments.example_environment_base import ExampleEnvironmentBase
1213

13-
# NOTE: Same pattern as other example envs — avoid heavy imports before AppLauncher.
14+
if TYPE_CHECKING:
15+
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
1416

1517

1618
class DexsuiteLiftEnvironment(ExampleEnvironmentBase):
@@ -21,7 +23,7 @@ class DexsuiteLiftEnvironment(ExampleEnvironmentBase):
2123

2224
name: str = "dexsuite_lift"
2325

24-
def get_env(self, args_cli: argparse.Namespace):
26+
def get_env(self, args_cli: argparse.Namespace) -> IsaacLabArenaEnvironment:
2527
import math
2628

2729
import isaaclab_tasks.manager_based.manipulation.dexsuite # noqa: F401

isaaclab_arena_environments/example_environment_base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6+
from __future__ import annotations
7+
68
import argparse
79
from abc import ABC, abstractmethod
10+
from typing import TYPE_CHECKING
811

9-
# NOTE(alexmillane, 2025.09.04): There is an issue with type annotation in this file.
10-
# We cannot annotate types which require the simulation app to be started in order to
11-
# import, because this file is used to retrieve CLI arguments, so it must be imported
12-
# before the simulation app is started.
13-
# TODO(alexmillane, 2025.09.04): Fix this.
12+
if TYPE_CHECKING:
13+
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
1414

1515

1616
class ExampleEnvironmentBase(ABC):
@@ -25,7 +25,7 @@ def __init__(self):
2525
self.hdr_registry = HDRImageRegistry()
2626

2727
@abstractmethod
28-
def get_env(self, args_cli: argparse.Namespace): # -> IsaacLabArenaEnvironment:
28+
def get_env(self, args_cli: argparse.Namespace) -> IsaacLabArenaEnvironment:
2929
pass
3030

3131
@abstractmethod

isaaclab_arena_environments/franka_put_and_close_door_environment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6+
from __future__ import annotations
7+
68
import argparse
9+
from typing import TYPE_CHECKING
710

811
from isaaclab_arena_environments.example_environment_base import ExampleEnvironmentBase
912

10-
# NOTE(alexmillane, 2025.09.04): There is an issue with type annotation in this file.
11-
# We cannot annotate types which require the simulation app to be started in order to
12-
# import, because this file is used to retrieve CLI arguments, so it must be imported
13-
# before the simulation app is started.
14-
# TODO(alexmillane, 2025.09.04): Fix this.
13+
if TYPE_CHECKING:
14+
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
1515

1616

1717
class FrankaPutAndCloseDoorEnvironment(ExampleEnvironmentBase):
@@ -24,7 +24,7 @@ class FrankaPutAndCloseDoorEnvironment(ExampleEnvironmentBase):
2424

2525
name = "franka_put_and_close_door"
2626

27-
def get_env(self, args_cli: argparse.Namespace):
27+
def get_env(self, args_cli: argparse.Namespace) -> IsaacLabArenaEnvironment:
2828
from isaaclab_arena.assets.object_base import ObjectType
2929
from isaaclab_arena.assets.object_reference import ObjectReference
3030
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment

isaaclab_arena_environments/galileo_g1_locomanip_pick_and_place_environment.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6+
from __future__ import annotations
7+
68
import argparse
79
import math
10+
from typing import TYPE_CHECKING
811

912
from isaaclab_arena_environments.example_environment_base import ExampleEnvironmentBase
1013

14+
if TYPE_CHECKING:
15+
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
16+
1117

1218
class GalileoG1LocomanipPickAndPlaceEnvironment(ExampleEnvironmentBase):
1319

1420
name: str = "galileo_g1_locomanip_pick_and_place"
1521

16-
def get_env(self, args_cli: argparse.Namespace):
22+
def get_env(self, args_cli: argparse.Namespace) -> IsaacLabArenaEnvironment:
1723
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
1824
from isaaclab_arena.scene.scene import Scene
1925
from isaaclab_arena.tasks.g1_locomanip_pick_and_place_task import G1LocomanipPickAndPlaceTask

isaaclab_arena_environments/galileo_pick_and_place_environment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6+
from __future__ import annotations
7+
68
import argparse
9+
from typing import TYPE_CHECKING
710

811
from isaaclab_arena_environments.example_environment_base import ExampleEnvironmentBase
912

10-
# NOTE(alexmillane, 2025.09.04): There is an issue with type annotation in this file.
11-
# We cannot annotate types which require the simulation app to be started in order to
12-
# import, because this file is used to retrieve CLI arguments, so it must be imported
13-
# before the simulation app is started.
14-
# TODO(alexmillane, 2025.09.04): Fix this.
13+
if TYPE_CHECKING:
14+
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
1515

1616

1717
class GalileoPickAndPlaceEnvironment(ExampleEnvironmentBase):
1818

1919
name: str = "galileo_pick_and_place"
2020

21-
def get_env(self, args_cli: argparse.Namespace): # -> IsaacLabArenaEnvironment:
21+
def get_env(self, args_cli: argparse.Namespace) -> IsaacLabArenaEnvironment:
2222
from isaaclab_arena.assets.object_reference import ObjectReference
2323
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
2424
from isaaclab_arena.scene.scene import Scene

isaaclab_arena_environments/gr1_open_microwave_environment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6+
from __future__ import annotations
7+
68
import argparse
9+
from typing import TYPE_CHECKING
710

811
from isaaclab_arena_environments.example_environment_base import ExampleEnvironmentBase
912

10-
# NOTE(alexmillane, 2025.09.04): There is an issue with type annotation in this file.
11-
# We cannot annotate types which require the simulation app to be started in order to
12-
# import, because this file is used to retrieve CLI arguments, so it must be imported
13-
# before the simulation app is started.
14-
# TODO(alexmillane, 2025.09.04): Fix this.
13+
if TYPE_CHECKING:
14+
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
1515

1616

1717
class Gr1OpenMicrowaveEnvironment(ExampleEnvironmentBase):
1818

1919
name: str = "gr1_open_microwave"
2020

21-
def get_env(self, args_cli: argparse.Namespace): # -> IsaacLabArenaEnvironment:
21+
def get_env(self, args_cli: argparse.Namespace) -> IsaacLabArenaEnvironment:
2222
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
2323
from isaaclab_arena.scene.scene import Scene
2424
from isaaclab_arena.tasks.open_door_task import OpenDoorTask

isaaclab_arena_environments/gr1_put_and_close_door_environment.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6+
from __future__ import annotations
7+
68
import argparse
79
import math
10+
from typing import TYPE_CHECKING
811

912
from isaaclab_arena.tasks.common.mimic_default_params import MIMIC_DATAGEN_CONFIG_DEFAULTS
1013
from isaaclab_arena_environments.example_environment_base import ExampleEnvironmentBase
1114

12-
# NOTE(alexmillane, 2025.09.04): There is an issue with type annotation in this file.
13-
# We cannot annotate types which require the simulation app to be started in order to
14-
# import, because this file is used to retrieve CLI arguments, so it must be imported
15-
# before the simulation app is started.
16-
# TODO(alexmillane, 2025.09.04): Fix this.
15+
if TYPE_CHECKING:
16+
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
1717

1818

1919
RANDOMIZATION_HALF_RANGE_X_M = 0.03
@@ -32,7 +32,7 @@ class GR1PutAndCloseDoorEnvironment(ExampleEnvironmentBase):
3232

3333
name = "put_item_in_fridge_and_close_door"
3434

35-
def get_env(self, args_cli: argparse.Namespace):
35+
def get_env(self, args_cli: argparse.Namespace) -> IsaacLabArenaEnvironment:
3636
from isaaclab.envs.mimic_env_cfg import MimicEnvCfg
3737
from isaaclab.utils import configclass
3838

isaaclab_arena_environments/gr1_table_multi_object_no_collision_environment.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@
1313
--num_envs 1 --enable_cameras gr1_table_multi_object_no_collision --embodiment gr1_joint
1414
"""
1515

16+
from __future__ import annotations
17+
1618
import argparse
19+
from typing import TYPE_CHECKING
1720

1821
from isaaclab_arena_environments.example_environment_base import ExampleEnvironmentBase
1922

23+
if TYPE_CHECKING:
24+
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
25+
2026
DEFAULT_TABLE_OBJECTS = [
2127
"cracker_box",
2228
"mustard_bottle",
@@ -36,7 +42,7 @@ class GR1TableMultiObjectNoCollisionEnvironment(ExampleEnvironmentBase):
3642

3743
name: str = "gr1_table_multi_object_no_collision"
3844

39-
def get_env(self, args_cli: argparse.Namespace): # -> IsaacLabArenaEnvironment:
45+
def get_env(self, args_cli: argparse.Namespace) -> IsaacLabArenaEnvironment:
4046
from isaaclab_arena.assets.object_reference import ObjectReference
4147
from isaaclab_arena.environments.isaaclab_arena_environment import IsaacLabArenaEnvironment
4248
from isaaclab_arena.relations.relations import IsAnchor, On

0 commit comments

Comments
 (0)