diff --git a/pyproject.toml b/pyproject.toml index 86ab12b38ceb..62071e5008c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ all = [ [tool.ruff] line-length = 120 -target-version = "py310" +target-version = "py312" # Exclude directories extend-exclude = [ @@ -98,6 +98,8 @@ ignore = [ "SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys() "UP006", # Use 'dict' instead of 'Dict' type annotation "UP018", # Unnecessary `float` call (rewrite as a literal) + "UP040", # TypeAlias annotation → `type` keyword (PEP 695, migrate later) + "UP047", # Generic function → type parameters (PEP 695, migrate later) ] [tool.ruff.lint.per-file-ignores] diff --git a/scripts/reinforcement_learning/rl_games/train.py b/scripts/reinforcement_learning/rl_games/train.py index f08edaaff7d7..fe8ffbef1268 100644 --- a/scripts/reinforcement_learning/rl_games/train.py +++ b/scripts/reinforcement_learning/rl_games/train.py @@ -24,7 +24,6 @@ import sys import time from datetime import datetime -from distutils.util import strtobool import gymnasium as gym from rl_games.common import env_configurations, vecenv @@ -36,6 +35,7 @@ from isaaclab.utils.dict import print_dict from isaaclab.utils.io import dump_yaml from isaaclab.utils.seed import configure_seed +from isaaclab.utils.string import strtobool from isaaclab_rl.rl_games import MultiObserver, PbtAlgoObserver, RlGamesGpuEnv, RlGamesVecEnvWrapper diff --git a/scripts/reinforcement_learning/rl_games/train_rl_games.py b/scripts/reinforcement_learning/rl_games/train_rl_games.py index 0cf210c27b2e..88089cad2725 100644 --- a/scripts/reinforcement_learning/rl_games/train_rl_games.py +++ b/scripts/reinforcement_learning/rl_games/train_rl_games.py @@ -15,7 +15,6 @@ import random import time from datetime import datetime -from distutils.util import strtobool from common import ( add_common_train_args, @@ -30,6 +29,8 @@ wrap_record_video, ) +from isaaclab.utils.string import strtobool + import isaaclab_tasks # noqa: F401 logger = logging.getLogger(__name__) diff --git a/source/isaaclab/changelog.d/ruff-target-py312.skip b/source/isaaclab/changelog.d/ruff-target-py312.skip new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/source/isaaclab/isaaclab/cli/commands/install.py b/source/isaaclab/isaaclab/cli/commands/install.py index 90fa929b69e5..5bcdc9641879 100644 --- a/source/isaaclab/isaaclab/cli/commands/install.py +++ b/source/isaaclab/isaaclab/cli/commands/install.py @@ -7,9 +7,8 @@ import re import shutil import sys -from pathlib import Path - import tomllib +from pathlib import Path from ..utils import ( ISAACLAB_ROOT, diff --git a/source/isaaclab/isaaclab/devices/haply/se3_haply.py b/source/isaaclab/isaaclab/devices/haply/se3_haply.py index 871aee4689f3..1632fa2d131a 100644 --- a/source/isaaclab/isaaclab/devices/haply/se3_haply.py +++ b/source/isaaclab/isaaclab/devices/haply/se3_haply.py @@ -344,7 +344,7 @@ async def _websocket_loop(self): await asyncio.sleep(1.0 / self.data_rate) - except asyncio.TimeoutError: + except TimeoutError: self.consecutive_timeouts += 1 # Check if timeout diff --git a/source/isaaclab/isaaclab/utils/string.py b/source/isaaclab/isaaclab/utils/string.py index 4e7790006ade..125400704b43 100644 --- a/source/isaaclab/isaaclab/utils/string.py +++ b/source/isaaclab/isaaclab/utils/string.py @@ -546,3 +546,27 @@ def list_intersection(list1: list[Any], list2: list[Any] | None) -> list[Any]: return list1 set2 = set(list2) return [x for x in list1 if x in set2] + + +def strtobool(val: str) -> bool: + """Convert a string representation of truth to True/False. + + True values are ``y``, ``yes``, ``t``, ``true``, ``on``, and ``1``. + False values are ``n``, ``no``, ``f``, ``false``, ``off``, and ``0``. + + Args: + val: The string to convert. + + Returns: + The boolean interpretation of *val*. + + Raises: + ValueError: If *val* is not a recognised truth string. + """ + v = val.lower() + if v in ("y", "yes", "t", "true", "on", "1"): + return True + elif v in ("n", "no", "f", "false", "off", "0"): + return False + else: + raise ValueError(f"invalid truth value {val!r}") diff --git a/source/isaaclab/test/cli/test_uv_run_pyproject.py b/source/isaaclab/test/cli/test_uv_run_pyproject.py index cec68c7bc9c5..3a8d1a194a57 100644 --- a/source/isaaclab/test/cli/test_uv_run_pyproject.py +++ b/source/isaaclab/test/cli/test_uv_run_pyproject.py @@ -8,9 +8,8 @@ from __future__ import annotations import re -from pathlib import Path - import tomllib +from pathlib import Path def _repo_root() -> Path: diff --git a/source/isaaclab/test/cli/test_wheel_builder_metadata.py b/source/isaaclab/test/cli/test_wheel_builder_metadata.py index a8c6e405a90c..04ed0679c4f1 100644 --- a/source/isaaclab/test/cli/test_wheel_builder_metadata.py +++ b/source/isaaclab/test/cli/test_wheel_builder_metadata.py @@ -8,9 +8,8 @@ from __future__ import annotations import ast -from pathlib import Path - import tomllib +from pathlib import Path def _repo_root() -> Path: diff --git a/tools/wheel_builder/gen_pyproject.py b/tools/wheel_builder/gen_pyproject.py index a8cf3fdd8d5d..bf9de00cc233 100644 --- a/tools/wheel_builder/gen_pyproject.py +++ b/tools/wheel_builder/gen_pyproject.py @@ -6,7 +6,6 @@ """Generate pyproject.toml for the isaaclab wheel from python_packages.toml.""" import sys - import tomllib if len(sys.argv) != 4: