Skip to content

Commit aa220db

Browse files
authored
Adds preview features for black formatter (#192)
# Description Adds `--preview` feature to the black formatter which also takes care of the string representations in the code. This feature will become the default setting in the next release of black (psf/black#1802). ## Type of change - New feature (non-breaking change which adds functionality) - This change requires a documentation update ## Checklist - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./orbit.sh --format` - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file
1 parent 36471c3 commit aa220db

File tree

31 files changed

+103
-76
lines changed

31 files changed

+103
-76
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: 23.3.0
44
hooks:
55
- id: black
6-
args: ["--line-length", "120"]
6+
args: ["--line-length", "120", "--preview"]
77
- repo: https://github.com/pycqa/flake8
88
rev: 6.0.0
99
hooks:

docs/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@
177177
"use_edit_page_button": True,
178178
"show_toc_level": 2,
179179
"use_sidenotes": True,
180-
"announcement": "⚠️This is a pre-release version of Orbit. Please report any issues on <a href='https://github.com/NVIDIA-Omniverse/orbit/issues'>GitHub</a>.",
180+
"announcement": (
181+
"⚠️This is a pre-release version of Orbit. Please report any issues on <a"
182+
" href='https://github.com/NVIDIA-Omniverse/orbit/issues'>GitHub</a>."
183+
),
181184
}
182185

183186
html_show_copyright = True

source/extensions/omni.isaac.orbit/omni/isaac/orbit/app.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ def __init__(self, launcher_args: argparse.Namespace | dict = None, **kwargs):
216216
if not set(kwargs.keys()).isdisjoint(launcher_args.keys()):
217217
overlapping_args = set(kwargs.keys()).intersection(launcher_args.keys())
218218
raise ValueError(
219-
f"Input `launcher_args` and `kwargs` both provided common attributes: {overlapping_args}. "
220-
"Please ensure that each argument is supplied to only one of them, as the AppLauncher cannot "
221-
"discern priority between them."
219+
f"Input `launcher_args` and `kwargs` both provided common attributes: {overlapping_args}."
220+
" Please ensure that each argument is supplied to only one of them, as the AppLauncher cannot"
221+
" discern priority between them."
222222
)
223223
launcher_args.update(kwargs)
224224

@@ -300,10 +300,10 @@ def add_app_launcher_args(parser: argparse.ArgumentParser) -> None:
300300
config = vars(known)
301301
if len(config) == 0:
302302
print(
303-
"[Warn][AppLauncher]: There are no arguments attached to the ArgumentParser object. "
304-
"If you have your own arguments, please load your own arguments before calling the "
305-
"`AppLauncher.add_app_launcher_args` method. This allows the method to check the validity "
306-
"of the arguments and perform checks for argument names."
303+
"[Warn][AppLauncher]: There are no arguments attached to the ArgumentParser object."
304+
" If you have your own arguments, please load your own arguments before calling the"
305+
" `AppLauncher.add_app_launcher_args` method. This allows the method to check the validity"
306+
" of the arguments and perform checks for argument names."
307307
)
308308
else:
309309
AppLauncher._check_argparser_config_params(config)
@@ -406,9 +406,9 @@ def _check_argparser_config_params(config: dict) -> None:
406406
for key, value in config.items():
407407
if key in applauncher_keys:
408408
raise ValueError(
409-
f"The passed ArgParser object already has the field '{key}'. This field will be added by "
410-
"AppLauncher.add_app_launcher_args(), and should not be added directly. Please remove the "
411-
"argument or rename it to a non-conflicting name."
409+
f"The passed ArgParser object already has the field '{key}'. This field will be added by"
410+
" `AppLauncher.add_app_launcher_args()`, and should not be added directly. Please remove the"
411+
" argument or rename it to a non-conflicting name."
412412
)
413413
# check that type of the passed keys are valid
414414
simulationapp_keys = set(AppLauncher._SIMULATIONAPP_CONFIG_TYPES.keys())
@@ -418,9 +418,9 @@ def _check_argparser_config_params(config: dict) -> None:
418418
expected_types = AppLauncher._SIMULATIONAPP_CONFIG_TYPES[key]
419419
if type(value) not in set(expected_types):
420420
raise ValueError(
421-
f"Invalid value type for the argument '{key}': {given_type}. Expected one of {expected_types}, "
422-
f"if intended to be ingested by the SimulationApp object. Please change the type if this "
423-
"intended for the SimulationApp or change the name of the argument to avoid name conflicts."
421+
f"Invalid value type for the argument '{key}': {given_type}. Expected one of {expected_types},"
422+
" if intended to be ingested by the SimulationApp object. Please change the type if this"
423+
" intended for the SimulationApp or change the name of the argument to avoid name conflicts."
424424
)
425425
# Print out values which will be used
426426
print(f"[INFO][AppLauncher]: The argument '{key}' will be used to configure the SimulationApp.")
@@ -441,22 +441,22 @@ def _config_resolution(self, launcher_args: dict):
441441
# Value checking on LIVESTREAM
442442
if livestream_env not in livestream_valid_vals:
443443
raise ValueError(
444-
f"Invalid value for environment variable `LIVESTREAM`: {livestream_env} . "
445-
f"Expected: {livestream_valid_vals}."
444+
f"Invalid value for environment variable `LIVESTREAM`: {livestream_env} ."
445+
f" Expected: {livestream_valid_vals}."
446446
)
447447
# We allow livestream kwarg to supersede LIVESTREAM envvar
448448
if livestream_arg >= 0:
449449
if livestream_arg in livestream_valid_vals:
450450
self._livestream = livestream_arg
451451
# print info that we overrode the env-var
452452
print(
453-
f"[INFO][AppLauncher]: Input keyword argument `livestream={livestream_arg}` has overridden "
454-
f"the environment variable `LIVESTREAM={livestream_env}`."
453+
f"[INFO][AppLauncher]: Input keyword argument `livestream={livestream_arg}` has overridden"
454+
f" the environment variable `LIVESTREAM={livestream_env}`."
455455
)
456456
else:
457457
raise ValueError(
458-
f"Invalid value for input keyword argument `livestream`: {livestream_arg} . "
459-
f"Expected: {livestream_valid_vals}."
458+
f"Invalid value for input keyword argument `livestream`: {livestream_arg} ."
459+
f" Expected: {livestream_valid_vals}."
460460
)
461461
else:
462462
self._livestream = livestream_env
@@ -472,8 +472,7 @@ def _config_resolution(self, launcher_args: dict):
472472
# Value checking on HEADLESS
473473
if headless_env not in headless_valid_vals:
474474
raise ValueError(
475-
f"Invalid value for environment variable `HEADLESS`: {headless_env} . "
476-
f"Expected: {headless_valid_vals}."
475+
f"Invalid value for environment variable `HEADLESS`: {headless_env} . Expected: {headless_valid_vals}."
477476
)
478477
# We allow headless kwarg to supersede HEADLESS envvar if headless_arg does not have the default value
479478
# Note: Headless is always true when livestreaming
@@ -485,13 +484,13 @@ def _config_resolution(self, launcher_args: dict):
485484
# inform who has toggled the headless flag
486485
if self._livestream == livestream_arg:
487486
print(
488-
f"[INFO][AppLauncher]: Input keyword argument `livestream={self._livestream}` has implicitly "
489-
f"overridden the environment variable `HEADLESS={headless_env}` to True."
487+
f"[INFO][AppLauncher]: Input keyword argument `livestream={self._livestream}` has implicitly"
488+
f" overridden the environment variable `HEADLESS={headless_env}` to True."
490489
)
491490
elif self._livestream == livestream_env:
492491
print(
493-
f"[INFO][AppLauncher]: Environment variable `LIVESTREAM={self._livestream}` has implicitly "
494-
f"overridden the environment variable `HEADLESS={headless_env}` to True."
492+
f"[INFO][AppLauncher]: Environment variable `LIVESTREAM={self._livestream}` has implicitly"
493+
f" overridden the environment variable `HEADLESS={headless_env}` to True."
495494
)
496495
else:
497496
# Headless needs to be a bool to be ingested by SimulationApp
@@ -515,8 +514,8 @@ def _config_resolution(self, launcher_args: dict):
515514
self._ros = ros_arg
516515
# print info that we overrode the env-var
517516
print(
518-
f"[INFO][AppLauncher]: Input keyword argument `ros={ros_arg}` has overridden "
519-
f"the environment variable `ROS_ENABLED={ros_env}`."
517+
f"[INFO][AppLauncher]: Input keyword argument `ros={ros_arg}` has overridden"
518+
f" the environment variable `ROS_ENABLED={ros_env}`."
520519
)
521520
else:
522521
raise ValueError(

source/extensions/omni.isaac.orbit/omni/isaac/orbit/assets/articulation/articulation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ def _process_actuators_cfg(self):
508508
# check if any joints are found
509509
if len(joint_names) == 0:
510510
raise ValueError(
511-
f"No joints found for actuator group: {actuator_name} with joint name expression: "
512-
f"{actuator_cfg.joint_names_expr}."
511+
f"No joints found for actuator group: {actuator_name} with joint name expression:"
512+
f" {actuator_cfg.joint_names_expr}."
513513
)
514514
# for efficiency avoid indexing when over all indices
515515
if len(joint_names) == self.num_joints:
@@ -524,8 +524,8 @@ def _process_actuators_cfg(self):
524524
)
525525
# log information on actuator groups
526526
carb.log_info(
527-
f"Actuator collection: {actuator_name} with model '{actuator_cfg.class_type.__name__}' and "
528-
f"joint names: {joint_names} [{joint_ids}]."
527+
f"Actuator collection: {actuator_name} with model '{actuator_cfg.class_type.__name__}' and"
528+
f" joint names: {joint_names} [{joint_ids}]."
529529
)
530530
# store actuator group
531531
self.actuators[actuator_name] = actuator

source/extensions/omni.isaac.orbit/omni/isaac/orbit/compat/utils/kit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ def apply_physics_material(prim_path: str, material_path: str, weaker_than_desce
448448
has_particle_system = prim.IsA(PhysxSchema.PhysxParticleSystem)
449449
if not (has_collider or has_deformable_body or has_particle_system):
450450
raise ValueError(
451-
f"Cannot apply physics material on prim '{prim_path}'. It is neither a collider, nor a deformable body, nor a particle system."
451+
f"Cannot apply physics material on prim '{prim_path}'. It is neither a collider,"
452+
" nor a deformable body, nor a particle system."
452453
)
453454
# obtain material binding API
454455
if prim.HasAPI(UsdShade.MaterialBindingAPI):

source/extensions/omni.isaac.orbit/omni/isaac/orbit/compat/utils/mdp/observation_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,10 @@ def _prepare_observation_terms(self):
376376
# Think: Check for cases when kwargs are set inside the function?
377377
if len(args) > 2:
378378
if set(args[2:]) != set(term_params):
379-
msg = f"Observation term '{term_name}' expects parameters: {args[2:]}, but {term_params} provided."
379+
msg = (
380+
f"Observation term '{term_name}' expects parameters: {args[2:]}, but"
381+
f" {term_params} provided."
382+
)
380383
raise ValueError(msg)
381384
# add function to list
382385
self._group_obs_term_names[group_name].append(term_name)

source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/mdp/actions/binary_joint_actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def __init__(self, cfg: actions_cfg.BinaryJointActionCfg, env: BaseEnv) -> None:
5252
self._num_joints = len(self._joint_ids)
5353
# log the resolved joint names for debugging
5454
carb.log_info(
55-
f"Resolved joint names for the action term {self.__class__.__name__}: {self._joint_names} [{self._joint_ids}]"
55+
f"Resolved joint names for the action term {self.__class__.__name__}:"
56+
f" {self._joint_names} [{self._joint_ids}]"
5657
)
5758

5859
# create tensors for raw and processed actions

source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/mdp/actions/joint_actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def __init__(self, cfg: actions_cfg.JointActionCfg, env: BaseEnv) -> None:
5959
self._num_joints = len(self._joint_ids)
6060
# log the resolved joint names for debugging
6161
carb.log_info(
62-
f"Resolved joint names for the action term {self.__class__.__name__}: {self._joint_names} [{self._joint_ids}]"
62+
f"Resolved joint names for the action term {self.__class__.__name__}:"
63+
f" {self._joint_names} [{self._joint_ids}]"
6364
)
6465

6566
# Avoid indexing across all joints for efficiency

source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/mdp/actions/non_holonomic_actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def __init__(self, cfg: actions_cfg.NonHolonomicActionCfg, env: BaseEnv):
8888
self._joint_names = [x_joint_name[0], y_joint_name[0], yaw_joint_name[0]]
8989
# log info for debugging
9090
carb.log_info(
91-
f"Resolved joint names for the action term {self.__class__.__name__}: {self._joint_names} [{self._joint_ids}]"
91+
f"Resolved joint names for the action term {self.__class__.__name__}:"
92+
f" {self._joint_names} [{self._joint_ids}]"
9293
)
9394
carb.log_info(
9495
f"Resolved body name for the action term {self.__class__.__name__}: {self._body_name} [{self._body_idx}]"

source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/mdp/actions/task_space_actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ def __init__(self, cfg: actions_cfg.DifferentialInverseKinematicsActionCfg, env:
6868

6969
# log info for debugging
7070
carb.log_info(
71-
f"Resolved joint names for the action term {self.__class__.__name__}: {self._joint_names} [{self._joint_ids}]"
71+
f"Resolved joint names for the action term {self.__class__.__name__}:"
72+
f" {self._joint_names} [{self._joint_ids}]"
7273
)
7374
carb.log_info(
7475
f"Resolved body name for the action term {self.__class__.__name__}: {self._body_name} [{self._body_idx}]"

0 commit comments

Comments
 (0)