Skip to content

Commit 28d5b01

Browse files
Mayankm96matthewtrepte
authored andcommitted
Switches code formatting to black (isaac-sim#4387)
# Description Using Ruff for everything. ## Type of change - Breaking change (existing functionality will not work without user modification) ## Checklist - [ ] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [ ] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [ ] I have made corresponding changes to the documentation - [ ] 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 - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: Mayank Mittal <12863862+Mayankm96@users.noreply.github.com>
1 parent 543de41 commit 28d5b01

File tree

125 files changed

+835
-761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+835
-761
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ repos:
1111
- id: ruff
1212
args: ["--fix"]
1313
# Run the formatter
14-
# - id: ruff-format
15-
- repo: https://github.com/python/black
16-
rev: 24.3.0
17-
hooks:
18-
- id: black
14+
- id: ruff-format
1915
- repo: https://github.com/pre-commit/pre-commit-hooks
2016
rev: v6.0.0
2117
hooks:

.vscode/tools/settings.template.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@
6161
],
6262
// This enables python language server. Seems to work slightly better than jedi:
6363
"python.languageServer": "Pylance",
64-
// We use "black" as a formatter:
65-
"black-formatter.args": ["--line-length", "120", "--unstable"],
66-
// Use ruff as a linter
64+
// Use ruff as a formatter and linter
6765
"ruff.configuration": "${workspaceFolder}/pyproject.toml",
6866
// Use docstring generator
6967
"autoDocstring.docstringFormat": "google",

docs/source/overview/developer-guide/vs_code.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,13 @@ refer to the `VSCode documentation <https://code.visualstudio.com/docs/python/en
8080
Setting up formatting and linting
8181
---------------------------------
8282

83-
We use `black <https://black.readthedocs.io/en/stable/>`_ as a formatter and `ruff <https://github.com/astral-sh/ruff/>`_ as a linter. These are configured in the ``.vscode/settings.json`` file:
83+
We use `ruff <https://github.com/astral-sh/ruff/>`_ as a formatter and linter.
84+
These are configured in the ``.vscode/settings.json`` file:
8485

8586
.. code-block:: json
8687
8788
{
88-
"black-formatter.args": ["--line-length", "120", "--unstable"],
8989
"ruff.configuration": "${workspaceFolder}/pyproject.toml",
9090
}
9191
92-
The black formatter will automatically format your code to match the project's style guide (120 character line length).
9392
The ruff linter will show warnings and errors in your code to help you follow Python best practices and the project's coding standards.

docs/source/refs/contributing.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ Tools
515515
We use the following tools for maintaining code quality:
516516

517517
* `pre-commit <https://pre-commit.com/>`__: Runs a list of formatters and linters over the codebase.
518-
* `black <https://black.readthedocs.io/en/stable/>`__: The uncompromising code formatter.
519518
* `ruff <https://github.com/astral-sh/ruff/>`__: An extremely fast Python linter and formatter.
520519

521520
Please check `here <https://pre-commit.com/#install>`__ for instructions

pyproject.toml

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

6-
[tool.black]
7-
line-length = 120
8-
target-version = ["py311"]
9-
preview = true
10-
unstable = true
11-
126
[tool.ruff]
137
line-length = 120
148
target-version = "py310"
@@ -103,14 +97,8 @@ section-order = [
10397
"isaaclab-tasks" = ["isaaclab_tasks"]
10498

10599
[tool.ruff.format]
106-
# Use Black-compatible formatting
107-
quote-style = "double"
108-
indent-style = "space"
109-
skip-magic-trailing-comma = false
110-
line-ending = "auto"
111-
preview = true
112-
113-
# docstring-code-format = true
100+
101+
docstring-code-format = true
114102

115103
[tool.pyright]
116104

scripts/benchmarks/benchmark_cameras.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ def get_utilization_percentages(reset: bool = False, max_values: list[float] = [
546546

547547
# GPU utilization using pynvml
548548
if torch.cuda.is_available():
549-
550549
if args_cli.autotune:
551550
pynvml.nvmlInit() # Initialize NVML
552551
for i in range(torch.cuda.device_count()):
@@ -663,7 +662,6 @@ def run_simulator(
663662
# Loop through all camera lists and their data_types
664663
for camera_list, data_types, label in zip(camera_lists, camera_data_types, labels):
665664
for cam_idx, camera in enumerate(camera_list):
666-
667665
if env is None: # No env, need to step cams manually
668666
# Only update the camera if it hasn't been updated as part of scene_entities.update ...
669667
camera.update(dt=sim.get_physics_dt())

scripts/demos/bipeds.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ def design_scene(sim: sim_utils.SimulationContext) -> tuple[list, torch.Tensor]:
5656
cfg.func("/World/Light", cfg)
5757

5858
# Define origins
59-
origins = torch.tensor([
60-
[0.0, -1.0, 0.0],
61-
[0.0, 0.0, 0.0],
62-
[0.0, 1.0, 0.0],
63-
]).to(device=sim.device)
59+
origins = torch.tensor(
60+
[
61+
[0.0, -1.0, 0.0],
62+
[0.0, 0.0, 0.0],
63+
[0.0, 1.0, 0.0],
64+
]
65+
).to(device=sim.device)
6466

6567
# Robots
6668
cassie = Articulation(CASSIE_CFG.replace(prim_path="/World/Cassie"))

scripts/demos/sensors/contact_sensor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene):
9999

100100
# Simulate physics
101101
while simulation_app.is_running():
102-
103102
if count % 500 == 0:
104103
# reset counter
105104
count = 0

scripts/demos/sensors/frame_transformer_sensor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene):
9595

9696
# Simulate physics
9797
while simulation_app.is_running():
98-
9998
if count % 500 == 0:
10099
# reset counter
101100
count = 0

scripts/demos/sensors/imu_sensor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene):
6666

6767
# Simulate physics
6868
while simulation_app.is_running():
69-
7069
if count % 500 == 0:
7170
# reset counter
7271
count = 0

0 commit comments

Comments
 (0)