AcademySoftwareFoundation / AcademySoftwareFoundation/OpenTimelineIO
Add/Build type-hints for python package
- Dominant language
- C++
- Stars
- 2k
- Forks
- 351
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 1
Description
## Feature Request
Add type hints to the python package, for both native python code and compiled code.
## Description
Type hints are incredibly value in modern python, particularly for library code that may be unknown to developers! Type hints allow our IDEs to auto-complete, catch errors, and make simplify code discovery. I know not everybody loves type hints, but as a library, I believe OpenTimelineIO would benefit a lot from them in terms of automatic tooling integration and developer onboarding!
This is obviously pretty easy in the native python code, but in the pybind11 code it's slightly more tricky. Theoretically you can use `mypy stubgen` to do this with compiled modules? Is there a native pybind11 way of doing this? I'm not a C++ developer and have never touched pybind, so unfortunately I don't know for sure what the ideal workflow is here.
At my job, we have a mypy validated package that uses OpenTimelineIO, and I've spent a few hours trying to set up my own stub files for OTIO using mypy stubgen. It works _fairly_ well, but it's not perfect. Possibly good enough for release though!
Perhaps this is a two parter -
1) Add type hints to external facing python code (easy)
2) At package build/deploy time, use a command like `mypy stubgen -m opentimelineio` to generate .pyi files to be included in the package.
## Context
Add any other context here, such as simulated output, or screenshots, that might help clarify the request.
Contributor guide
Research direction
Start by surveying the native Python package and the compiled extension exposed through the package build/deploy process. Compare inline type hints with `mypy stubgen` output, then define a complete approach for both parts and verify that the resulting hints or `.pyi` files are included in the distributed package.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100