In addition to general fine-tuning of the stubs to improve their accuracy, this release also adds docstrings to the stub files. While these aren't really related to typing, including them in the stub files allows many IDEs to read and display them without having to inspect the runtime objects dynamically. It's worth noting that, while both the runtime docstrings and those in stubs are generated from comments stored by Interrogate, they aren't always the same. Most obviously, the stub docstrings include comments from different overloads of a function, noting the signature they apply to.
Other notable changes include:
- The minimum required version of Python has been lowered to 3.7 by importing from `typing_extensions` instead of `typing` for newer features.
- `NodePath` is now treaded as a generic type with respect to the type of node it points to.
- In some cases, stubs are skipped for methods and attributes implied by inheritance.
- All enum values exposed to Python as integers are now annotated with `typing.Final`.
- Where possible, method overloads with differing parameter counts are merged by making the final parameter optional.
- With the help of some `type: ignore` comments, the stubs now pass a Mypy check.
While the utility of the package has been greatly improved, it's still incomplete. Close to 100% of the types, methods, and variables available at runtime are covered by the stubs, but their typing isn't always as accurate as it could be. The size of Panda3D means that there are huge chunks that I've never even touched, so I would request that anyone interested in the idea of type-checking Panda3D programs try out the stubs and report any bugs or inaccuracies they come across. The stubs won't be as useful as they can be without insight into how Panda3D is used in practice.