IsaacLab
IsaacLab copied to clipboard
Adds pre-commit to declare `isaacsim.core.utils` as banned-api
Description
Prevent isaacsim.core.utils to be used in future PRs using the banned-api from ruff. https://docs.astral.sh/ruff/rules/banned-api/
source/isaaclab/test/terrains/test_terrain_generator.py:20:8: TID251 `isaacsim.core.utils` is banned: Do not import from isaacsim.core.utils; use internal framework utilities instead.
|
18 | import torch
19 |
20 | import isaacsim.core.utils.torch as torch_utils
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251
21 | import pytest
Idea from @Mayankm96
Dependes on #3923 and #3924
Type of change
- New feature (non-breaking change which adds functionality)
Checklist
- [x] I have read and understood the contribution guidelines
- [x] I have run the
pre-commitchecks with./isaaclab.sh --format - [x] 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.tomlfile - [x] I have added my name to the
CONTRIBUTORS.mdor my name already exists there
Greptile Overview
Greptile Summary
adds pre-commit hook for ruff linter to enforce ban on isaacsim.core.utils imports via TID251 rule
-
.pre-commit-config.yaml: adds ruff v0.14.3 hook with--fixand--exit-non-zero-on-fixflags -
pyproject.toml: enables TID251 (banned-api) and bansisaacsim.core.utils,.prims, and.stagesubmodules -
critical issue: configuration missing
isaacsim.core.utils.torch, which is imported in 9 files and won't be caught by current rules
Confidence Score: 2/5
- safe to merge after adding missing
isaacsim.core.utils.torchto banned-api list - pre-commit hook is correctly configured, but banned-api rules incomplete - missing
.torchsubmodule means 9 files importing it won't trigger the ban, defeating the PR's purpose -
pyproject.tomlneedsisaacsim.core.utils.torchadded to banned-api config
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| pyproject.toml | 2/5 | adds ruff banned-api config for isaacsim.core.utils, but missing .torch submodule |
| .pre-commit-config.yaml | 5/5 | adds ruff pre-commit hook with --fix and --exit-non-zero-on-fix args, correctly configured |
Sequence Diagram
sequenceDiagram
participant Dev as Developer
participant PreCommit as Pre-commit Hook
participant Ruff as Ruff Linter
participant Config as pyproject.toml
Dev->>Dev: writes code importing isaacsim.core.utils
Dev->>PreCommit: git commit
PreCommit->>Ruff: run ruff check with TID251
Ruff->>Config: read banned-api rules
Config-->>Ruff: isaacsim.core.utils patterns
Ruff->>Ruff: scan code for banned imports
alt banned import found
Ruff-->>PreCommit: exit non-zero with error
PreCommit-->>Dev: commit blocked with error message
Dev->>Dev: fix by using isaaclab internal utilities
else no banned imports
Ruff-->>PreCommit: exit zero
PreCommit-->>Dev: commit succeeds
end