habitat-sim icon indicating copy to clipboard operation
habitat-sim copied to clipboard

Add stubs to python bindings to provide typing information.

Open 0mdc opened this issue 1 year ago • 2 comments
trafficstars

Motivation and Context

This changeset adds stubs to python bindings to provide typing information. Stub generation depends on pybind11-stubgen.

https://github.com/facebookresearch/habitat-sim/assets/110583667/86593700-7896-4dc5-9ca7-a6d077beaad9

How to test:

  • pip install pybind11-stubgen.
  • Build habitat-sim normally.
  • Import the package in another project, and explore types in your IDE.

WIP:

  • Stubs contain some errors, but they mostly work.
  • CI is not yet handled.
  • Ideally, creating a stub package would scale better, but I could not make it work with bindings. See PEP 561.

How Has This Been Tested

Tested by importing habitat_sim in an external Python file.

Types of changes

  • [x] New feature (non-breaking change which adds functionality)

Checklist

  • [x] My code follows the code style of this project.
  • [x] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [x] I have completed my CLA (see CONTRIBUTING)
  • [x] I have added tests to cover my changes.
  • [x] All new and existing tests passed.

0mdc avatar Jun 25 '24 19:06 0mdc

Eventually it would be good to separate the binding process so that all the enums and classes are instantiated in appropriate order and then all their method bindings are added. This will address circular refs between class methods, where each class has a method argument referencing the other class.

jturner65 avatar Jan 22 '25 17:01 jturner65

That I'm (partially) handling in the m.css stub output already (#2477) -- there it's the types first and functions after. Doesn't handle type dependencies yet but internally it has knowledge about their dependencies so it could attempt to either sort them or make "forward declarations" when dependencies are cyclic (i.e., stringified annotations).

mosra avatar Jan 22 '25 17:01 mosra

Hi @0mdc!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

meta-cla[bot] avatar Oct 22 '25 22:10 meta-cla[bot]