• Mayank Mittal's avatar
    Fixes support for `classmethod` when defining a configclass (#901) · cdfa954f
    Mayank Mittal authored
    # Description
    
    Previously, the configclass instance did not properly parse
    classmethods. For instance, the following would fail:
    
    ```python
    from __future__ import annotations
    
    """Launch Isaac Sim Simulator first."""
    
    from omni.isaac.lab.app import AppLauncher
    
    # launch omniverse app
    app_launcher = AppLauncher(headless=True)
    
    """Rest everything follows."""
    
    from omni.isaac.lab.utils.configclass import configclass
    
    
    @configclass
    class DummyClass:
    
        a: int = 5
    
        def instance_method(self):
            print("Value of a: ", self.a)
    
        @classmethod
        def class_method(cls, value: int) -> DummyClass:
            return cls(a=value)
    
    
    cfg = DummyClass()
    
    # check all methods are callable
    cfg.instance_method()
    new_cfg1 = cfg.class_method(20)
    
    # create the same config instance using class method
    new_cfg2 = DummyClass.class_method(20)
    ```
    
    This MR fixes the checks to make sure class-methods remain bound to the
    class and do not become instance variables.
    
    ## Type of change
    
    - Bug fix (non-breaking change which fixes an issue)
    
    ## Checklist
    
    - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
    `./isaaclab.sh --format`
    - [ ] I have made corresponding changes to the documentation
    - [x] My changes generate no new warnings
    - [x] I have added tests that prove my fix is effective or that my
    feature works
    - [x] I have updated the changelog and the corresponding version in the
    extension's `config/extension.toml` file
    - [x] I have added my name to the `CONTRIBUTORS.md` or my name already
    exists there
    cdfa954f
Name
Last commit
Last update
..
omni.isaac.lab Loading commit data...
omni.isaac.lab_assets Loading commit data...
omni.isaac.lab_tasks Loading commit data...